Class DirectoryValidator
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDirectoryValidator(List<File> dirsToCheck) Creates DirectoryValidator to ensure given directories -
Method Summary
Modifier and TypeMethodDescriptionensureDirs(boolean isDebug) This method is ensuring, that specified directories will exists after call and will have enough permissions.private static DirectoryCheckResultsensureDirs(List<File> dirs, boolean isDebug) static DirectoryCheckResultThis method is package private for testing purposes only.
-
Field Details
-
LOG
-
dirsToCheck
-
-
Constructor Details
-
DirectoryValidator
-
-
Method Details
-
ensureDirs
This method is ensuring, that specified directories will exists after call and will have enough permissions.This methods is trying to create the directories if they are not present and is testing if can be written inside. All checks are done in bulk. If one or more defect is found, user is warned via dialogue in gui mode (again in bulk). In headless mode stdout/stderr is enough, as application (both gui and headless) should not stop to work, but continue to run with hope that corrupted dirs will not be necessary
- Parameters:
isDebug- output debug information- Returns:
- result of directory checks
-
ensureDirs
-
testDir
public static DirectoryCheckResult testDir(File f, boolean verbose, boolean testSubdir, boolean isDebug) This method is package private for testing purposes only.This method verify that directory exists, is directory, file and directory can be created, file can be written into, and subdirectory can be written into.
Some steps may looks like redundant, but some permission settings really allow to create file but not directory and vice versa. Also some settings can allow to create file or directory which can not be written into. (eg ACL or network disks)
-