Class FileSystemUtility
java.lang.Object
org.refcodes.filesystem.FileSystemUtility
-
Method Summary
Modifier and TypeMethodDescriptionstatic voiddeleteFiles(FileSystem aFileSystem, String aPath, boolean isRecursively) Deletes the entries found for the given path.static StringGets the name portion from the provided key (the key without the path portion).static StringGets the path portion from the provided key (the key without the name portion).static StringCreates a key from the given path portion and name portion.static FileHandletoNormalizedFileHandle(FileHandle aFileHandle, FileSystem aFileSystem) Test whether the given key may jail break from the name space.static StringtoNormalizedKey(String aKey, FileSystem aFileSystem) Truncates any prefixed path separator as we assemble our new path with the according namespace in front.static StringtoNormalizedName(String aName, FileSystem aFileSystem) Truncates any prefixed path separator as we assemble our new path with the according namespace in front.static StringtoNormalizedPath(String aPath) Normalizes the given path.static StringtoNormalizedPath(String aPath, FileSystem aFileSystem) Truncates any prefixed path separator as we assemble our new path with the according namespace in front.static StringtoTruncated(String aPath) Truncates any prefixed path separator as we assemble our new path with the according namespace in front.
-
Method Details
-
toNormalizedPath
Normalizes the given path. Some implementations have problems with a beginning separator character. This method removes the beginning separator, also replaces all "/" to the valid separator and returns the result.- Parameters:
aPath- The path to be normalized- Returns:
- The normalized path
-
getName
-
getPath
-
toKey
-
deleteFiles
Deletes the entries found for the given path.- Parameters:
aFileSystem- the file systemaPath- The path where to look whether there are file (handle)s or not.isRecursively- When true all children of that path are examined as well.
-
toTruncated
-
toNormalizedPath
public static String toNormalizedPath(String aPath, FileSystem aFileSystem) throws IllegalPathException Truncates any prefixed path separator as we assemble our new path with the according namespace in front. Test whether the given path may jail break from the name space. In case this "could" be the case, anIllegalPathExceptionis thrown.- Parameters:
aPath- The path to be checked.aFileSystem- The file system to use to get additional information.- Returns:
- The truncated path.
- Throws:
IllegalPathException- in case the path may jail break the name space.
-
toNormalizedKey
public static String toNormalizedKey(String aKey, FileSystem aFileSystem) throws IllegalKeyException Truncates any prefixed path separator as we assemble our new path with the according namespace in front. Test whether the given key may jail break from the name space. In case this "could" be the case, anIllegalKeyExceptionis thrown.- Parameters:
aKey- The key to be checked.aFileSystem- The file system to use to get additional information.- Returns:
- The truncated key.
- Throws:
IllegalKeyException- in case the key may jail break the name space.
-
toNormalizedName
public static String toNormalizedName(String aName, FileSystem aFileSystem) throws IllegalNameException Truncates any prefixed path separator as we assemble our new path with the according namespace in front. Test whether the given key may jail break from the name space. In case this "could" be the case, anIllegalKeyExceptionis thrown.- Parameters:
aName- The key to be checked.aFileSystem- The file system to use to get additional information.- Returns:
- The truncated key.
- Throws:
IllegalNameException- in case the name may jail break the name space.
-
toNormalizedFileHandle
public static FileHandle toNormalizedFileHandle(FileHandle aFileHandle, FileSystem aFileSystem) throws IllegalFileException Test whether the given key may jail break from the name space. In case this "could" be the case, anIllegalKeyExceptionis thrown.- Parameters:
aFileHandle- The file handle to be checked.aFileSystem- The file system to use to get additional information.- Returns:
- the file handle
- Throws:
IllegalFileException- in case the key may jail break the name space.
-