java.lang.Object
org.refcodes.filesystem.FileSystemUtility
The Class FileSystemUtility.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
deleteFiles
(FileSystem aFileSystem, String aPath, boolean isRecursively) Deletes the entries found for the given path.static String
Gets the name portion from the provided key (the key without the path portion).static String
Gets the path portion from the provided key (the key without the name portion).static String
Creates a key from the given path portion and name portion.static FileHandle
toNormalizedFileHandle
(FileHandle aFileHandle, FileSystem aFileSystem) Test whether the given key may jail break from the name space.static String
toNormalizedKey
(String aKey, FileSystem aFileSystem) Truncates any prefixed path separator as we assemble our new path with the according namespace in front.static String
toNormalizedName
(String aName, FileSystem aFileSystem) Truncates any prefixed path separator as we assemble our new path with the according namespace in front.static String
toNormalizedPath
(String aPath) Normalizes the given path.static String
toNormalizedPath
(String aPath, FileSystem aFileSystem) Truncates any prefixed path separator as we assemble our new path with the according namespace in front.static String
toTruncated
(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
Gets the name portion from the provided key (the key without the path portion).- Parameters:
aKey
- The key from which to get the name portion- Returns:
- The name portion
-
getPath
Gets the path portion from the provided key (the key without the name portion).- Parameters:
aKey
- The key from which to get the path portion- Returns:
- The path portion
-
toKey
Creates a key from the given path portion and name portion.- Parameters:
aPath
- The path to useaName
- The name to use- Returns:
- The key
-
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
Truncates any prefixed path separator as we assemble our new path with the according namespace in front.- Parameters:
aPath
- The path to truncate.- Returns:
- The truncated path, e.g. no prefixed path delimiters.
-
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, anIllegalPathException
is 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, anIllegalKeyException
is 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, anIllegalKeyException
is 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, anIllegalKeyException
is 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.
-