/** * Returns <code>true</code> only if the proxied archive file has random read and write access, as reported * by {@link AbstractFile#isFileOperationSupported(FileOperation)}. If that is not the case, this archive has * read-only access and behaves just like a {@link com.mucommander.commons.file.archive.AbstractROArchiveFile}. * * @return true only if the proxied archive file has random read and write access */ @Override public boolean isWritable() { return file.isFileOperationSupported(FileOperation.RANDOM_READ_FILE) && file.isFileOperationSupported(FileOperation.RANDOM_WRITE_FILE); }
public boolean accept(AbstractFile file) { return file.isFileOperationSupported(op); } }
/** * Returns <code>true</code> if the specified file operation and corresponding method is supported by this * file implementation. See the {@link FileOperation} enum for a complete list of file operations and their * corresponding <code>AbstractFile</code> methods. * <p> * Note that even if <code>true</code> is returned, this doesn't ensure that the file operation will succeed: * additional conditions may be required for the operation to succeed and the corresponding method may throw an * <code>IOException</code> if those conditions are not met. * </p> * * @param op a file operation * @return <code>true</code> if the specified file operation is supported by this filesystem. * @see FileOperation */ public boolean isFileOperationSupported(FileOperation op) { return isFileOperationSupported(op, getClass()); }
private void tryCopyFilePermissions(AbstractFile sourceFile, AbstractFile destFile) { if(destFile.isFileOperationSupported(FileOperation.CHANGE_PERMISSION)) { try { destFile.importPermissions(sourceFile, FilePermissions.DEFAULT_FILE_PERMISSIONS); // use #importPermissions(AbstractFile, int) to avoid isDirectory test } catch(IOException e) { LOGGER.debug("failed to import "+sourceFile+" permissions into "+destFile, e); // Fail silently } } }
private void tryCopyFileDate(AbstractFile sourceFile, AbstractFile destFile) { if(destFile.isFileOperationSupported(FileOperation.CHANGE_DATE)) { try { destFile.changeDate(sourceFile.getDate()); } catch (IOException e) { LOGGER.debug("failed to change the date of "+destFile, e); // Fail silently } } }
@Override protected void toggleEnabledState() { AbstractFile firstFile = mainFrame.getActiveTable().getFileTableModel().getFileAt(0); // If there is no file at all, do not rely on the action being supported by the current folder as this // would be incorrect for some filesystems which do not support operations consistently across the // filesystem (e.g. S3). In that case, err on the safe side and enable the action, even if the operation // end up not being supported. setEnabled(firstFile==null || firstFile.isFileOperationSupported(FileOperation.CREATE_DIRECTORY)); }
protected void toggleEnabledState() { AbstractFile firstFile = mainFrame.getActiveTable().getFileTableModel().getFileAt(0); // If there is no file at all, do not rely on the action being supported by the current folder as this // would be incorrect for some filesystems which do not support operations consistently across the // filesystem (e.g. S3). In that case, err on the safe side and enable the action, even if the operation // end up not being supported. setEnabled(firstFile==null || firstFile.isFileOperationSupported(FileOperation.WRITE_FILE)); }
/** * Tests {@link AbstractFile#getTotalSpace()}. * * @throws IOException should not happen */ @Test public void testTotalSpace() throws IOException { if(tempFile.isFileOperationSupported(FileOperation.GET_TOTAL_SPACE)) testGetTotalSpaceSupported(); else testGetTotalSpaceUnsupported(); }
/** * Tests {@link AbstractFile#ls()}. * * @throws IOException should not happen */ @Test public void testLs() throws IOException { if(tempFile.isFileOperationSupported(FileOperation.LIST_CHILDREN)) testLsSupported(); else testLsUnsupported(); }
/** * Tests {@link AbstractFile#copyRemotelyTo(AbstractFile)}. * * @throws IOException should not happen * @throws NoSuchAlgorithmException should not happen */ @Test public void testCopyRemotelyTo() throws IOException, NoSuchAlgorithmException { if(tempFile.isFileOperationSupported(FileOperation.COPY_REMOTELY)) testCopyRemotelyToSupported(); else testCopyRemotelyToUnsupported(); }
/** * Tests the {@link AbstractFile#delete()} method in various situations. * * @throws IOException should not happen */ @Test public void testDelete() throws IOException { if(tempFile.isFileOperationSupported(FileOperation.DELETE)) testDeleteSupported(); else testDeleteUnsupported(); }
/** * Tests {@link AbstractFile#getFreeSpace()}. * * @throws IOException should not happen */ @Test public void testFreeSpace() throws IOException { if(tempFile.isFileOperationSupported(FileOperation.GET_FREE_SPACE)) testGetFreeSpaceSupported(); else testGetFreeSpaceUnsupported(); }
/** * Tests {@link AbstractFile#renameTo(AbstractFile)}. * * @throws IOException should not happen * @throws NoSuchAlgorithmException should not happen */ @Test public void testRenameTo() throws IOException, NoSuchAlgorithmException { if(tempFile.isFileOperationSupported(FileOperation.RENAME)) testRenameToSupported(); else testRenameToUnsupported(); }
/** * Tests the {@link AbstractFile#mkdir()} method in various situations. * * @throws IOException should not happen */ @Test public void testMkdir() throws IOException { if(tempFile.isFileOperationSupported(FileOperation.CREATE_DIRECTORY)) testMkdirSupported(); else testMkdirUnsupported(); }
/** * Tests {@link AbstractFile#changeDate(long)}, calling {@link #testChangeDateSupported()} or * {@link #testChangeDateUnsupported()} depending on whether or not the {@link FileOperation#CHANGE_DATE} * operation is supported. * * @throws IOException should not happen * @throws NoSuchAlgorithmException should not happen */ @Test public void testChangeDate() throws IOException, NoSuchAlgorithmException { if(tempFile.isFileOperationSupported(FileOperation.CHANGE_DATE)) testChangeDateSupported(); else testChangeDateUnsupported(); }
/** * Tests {@link AbstractFile#getInputStream()}, calling {@link #testGetInputStreamSupported()} or * {@link #testGetInputStreamUnsupported()} depending on whether or not the {@link FileOperation#READ_FILE} * operation is supported. * * @throws IOException should not happen * @throws NoSuchAlgorithmException should not happen */ @Test public void testGetInputStream() throws IOException, NoSuchAlgorithmException { if(tempFile.isFileOperationSupported(FileOperation.READ_FILE)) testGetInputStreamSupported(); else testGetInputStreamUnsupported(); }
/** * Tests {@link AbstractFile#getRandomAccessInputStream()}, calling {@link #testGetRandomAccessInputStreamSupported()} * or {@link #testGetRandomAccessInputStreamUnsupported()} depending on whether or not the * {@link FileOperation#RANDOM_READ_FILE} operation is supported. * * @throws IOException should not happen * @throws NoSuchAlgorithmException should not happen */ @Test public void testGetRandomAccessInputStream() throws IOException, NoSuchAlgorithmException { if(tempFile.isFileOperationSupported(FileOperation.RANDOM_READ_FILE)) testGetRandomAccessInputStreamSupported(); else testGetRandomAccessInputStreamUnsupported(); }
/** * Tests {@link AbstractFile#getAppendOutputStream()}, calling {@link #testGetAppendOutputStreamSupported()} * or {@link #testGetAppendOutputStreamUnsupported()} depending on whether or not the * {@link FileOperation#APPEND_FILE} operation is supported. * * @throws IOException should not happen * @throws NoSuchAlgorithmException should not happen */ @Test public void testGetAppendOutputStream() throws IOException, NoSuchAlgorithmException { if(tempFile.isFileOperationSupported(FileOperation.APPEND_FILE)) testGetAppendOutputStreamSupported(); else testGetAppendOutputStreamUnsupported(); }
/** * Tests {@link AbstractFile#changePermissions(int)}, calling {@link #testChangePermissionsSupported()} or * {@link #testChangePermissionsUnsupported()} depending on whether or not the {@link FileOperation#CHANGE_PERMISSION} * operation is supported. * * @throws IOException should not happen * @throws NoSuchAlgorithmException should not happen */ @Test public void testChangePermissions() throws IOException, NoSuchAlgorithmException { if(tempFile.isFileOperationSupported(FileOperation.CHANGE_PERMISSION)) testChangePermissionsSupported(); else testChangePermissionsUnsupported(); }
/** * Tests {@link AbstractFile#getOutputStream()}, calling {@link #testGetOutputStreamSupported()} * or {@link #testGetOutputStreamUnsupported()} depending on whether or not the * {@link FileOperation#WRITE_FILE} operation is supported. * * @throws IOException should not happen * @throws NoSuchAlgorithmException should not happen */ @Test public void testGetOutputStream() throws IOException, NoSuchAlgorithmException { if(tempFile.isFileOperationSupported(FileOperation.WRITE_FILE)) testGetOutputStreamSupported(); else testGetOutputStreamUnsupported(); }