diff --git a/common/source/java/ch/systemsx/cisd/common/filesystem/FileOperations.java b/common/source/java/ch/systemsx/cisd/common/filesystem/FileOperations.java index 16341d67ab229cca3ee0446a1949943a5de4854e..0242ce5e5cc0f7305f3b0da5eee76ac05ec8374d 100644 --- a/common/source/java/ch/systemsx/cisd/common/filesystem/FileOperations.java +++ b/common/source/java/ch/systemsx/cisd/common/filesystem/FileOperations.java @@ -310,6 +310,36 @@ public class FileOperations implements IFileOperations return FileUtilities.listFilesAndDirectories(directory, recursive, observerOrNull); } + public String checkPathFullyAccessible(File path, String kindOfPath) + { + return FileUtilities.checkPathFullyAccessible(path, kindOfPath); + } + + public String checkPathReadAccessible(File path, String kindOfPath) + { + return FileUtilities.checkPathReadAccessible(path, kindOfPath); + } + + public String checkDirectoryFullyAccessible(File directory, String kindOfDirectory) + { + return FileUtilities.checkDirectoryFullyAccessible(directory, kindOfDirectory); + } + + public String checkDirectoryReadAccessible(File directory, String kindOfDirectory) + { + return FileUtilities.checkDirectoryReadAccessible(directory, kindOfDirectory); + } + + public String checkFileFullyAccessible(File file, String kindOfFile) + { + return FileUtilities.checkFileFullyAccessible(file, kindOfFile); + } + + public String checkFileReadAccessible(File file, String kindOfFile) + { + return FileUtilities.checkFileReadAccessible(file, kindOfFile); + } + public void touch(File file) throws WrappedIOException { try diff --git a/common/source/java/ch/systemsx/cisd/common/filesystem/IFileOperations.java b/common/source/java/ch/systemsx/cisd/common/filesystem/IFileOperations.java index 7a8695fc0672c9a407609f17b3b34f25736d944a..458d304bf5dd0307ed140a8d9e9cb907a76879f1 100644 --- a/common/source/java/ch/systemsx/cisd/common/filesystem/IFileOperations.java +++ b/common/source/java/ch/systemsx/cisd/common/filesystem/IFileOperations.java @@ -189,6 +189,61 @@ public interface IFileOperations extends IFileRemover */ public List<File> listFilesAndDirectories(File directory, boolean recursive); + /** + * Checks whether a <var>path</var> of some <var>kind</var> is fully accessible to the program. + * + * @param kindOfPath description of given <var>path</var>. Mainly used for error messages. + * @return <code>null</code> if the <var>directory</var> is fully accessible and an error + * message describing the problem with the <var>directory</var> otherwise. + */ + public String checkPathFullyAccessible(final File path, final String kindOfPath); + + /** + * Checks whether a <var>path</var> of some <var>kind</var> is accessible for reading to the + * program. + * + * @param kindOfPath description of given <var>path</var>. Mainly used for error messages. + * @return <code>null</code> if the <var>directory</var> is fully accessible and an error + * message describing the problem with the <var>directory</var> otherwise. + */ + public String checkPathReadAccessible(final File path, final String kindOfPath); + + /** + * Checks whether a <var>directory</var> of some <var>kind</var> is fully accessible to the + * program (it's a directory, you can read and write in it) + * + * @return <code>null</code> if the <var>directory</var> is fully accessible and an error + * message describing the problem with the <var>directory</var> otherwise. + */ + public String checkDirectoryFullyAccessible(final File directory, final String kindOfDirectory); + + /** + * Checks whether a <var>directory</var> of some <var>kind</var> is accessible for reading to + * the program (it's a directory, you can read and write in it) + * + * @return <code>null</code> if the <var>directory</var> is accessible for reading and an error + * message describing the problem with the <var>directory</var> otherwise. + */ + public String checkDirectoryReadAccessible(final File directory, final String kindOfDirectory); + + /** + * Checks whether a <var>file</var> of some <var>kindOfFile</var> is accessible for reading to + * the program (so it's a file and you can read it) + * + * @return <code>null</code> if the <var>file</var> is accessible to reading and an error + * message describing the problem with the <var>file</var> otherwise. + */ + public String checkFileReadAccessible(final File file, final String kindOfFile); + + /** + * Checks whether a <var>file</var> of some <var>kindOfFile</var> is accessible for reading and + * writing to the program (so it's a file and you can read and write it) + * + * @return <code>null</code> if the <var>file</var> is fully accessible and an error message + * describing the problem with the <var>file</var> otherwise. + */ + public String checkFileFullyAccessible(final File file, final String kindOfFile); + /** * Sets the file's last modification time to the current time without changing the content. If * the file does not exist, create it empty.