Package nl.knaw.dans.bagit.util
Class PathUtils
java.lang.Object
nl.knaw.dans.bagit.util.PathUtils
Convenience class for dealing with various path issues
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
decodeFilname
(String encoded) as per https://github.com/jkunze/bagitspec/commit/152d42f6298b31a4916ea3f8f644ca4490494070 decode percent encoded filenamesstatic String
encodeFilename
(Path path) as per https://github.com/jkunze/bagitspec/commit/152d42f6298b31a4916ea3f8f644ca4490494070 encode any new lines or carriage returnsstatic String
generatePayloadOxum
(Path dataDir) Calculate the total file and byte count of the files in the payload directorystatic Path
getBagitDir
(Bag bag) With bagit version 2.0 (.bagit) bagit specific files are no longer at the bag root directory.static Path
getBagitDir
(Version version, Path bagRoot) With bagit version 2.0 (.bagit) bagit specific files are no longer at the bag root directory.static Path
getDataDir
(Bag bag) With bagit version 2.0 (.bagit) payload files are no longer in the "data" directory.static Path
getDataDir
(Version version, Path output) With bagit version 2.0 (.bagit) payload files are no longer in the "data" directory.static String
getFilename
(Path path) Needed to get rid of findbugs "dodgy code warnings" in regards to getting the filename of a path as a stringstatic boolean
Due to the way that windows handles hidden files vs.
-
Field Details
-
PAYLOAD_DIR_NAME
- See Also:
-
DOT_BAGIT_DIR_NAME
- See Also:
-
-
Constructor Details
-
PathUtils
private PathUtils()
-
-
Method Details
-
getFilename
Needed to get rid of findbugs "dodgy code warnings" in regards to getting the filename of a path as a string- Parameters:
path
- the path that you which to get the filename as a string- Returns:
- the filename or an empty string
-
decodeFilname
as per https://github.com/jkunze/bagitspec/commit/152d42f6298b31a4916ea3f8f644ca4490494070 decode percent encoded filenames- Parameters:
encoded
- the encoded filename- Returns:
- the decoded filename
-
encodeFilename
as per https://github.com/jkunze/bagitspec/commit/152d42f6298b31a4916ea3f8f644ca4490494070 encode any new lines or carriage returns- Parameters:
path
- the path to encode- Returns:
- the encoded filename
-
isHidden
Due to the way that windows handles hidden files vs. *nix we use this method to determine if a file or folder is really hidden- Parameters:
path
- the file or folder to check if hidden- Returns:
- if the file or folder is hidden
- Throws:
IOException
- if there is an error reading the file/folder
-
getDataDir
With bagit version 2.0 (.bagit) payload files are no longer in the "data" directory. This method accounts for this and will return the directory that contains the payload files- Parameters:
bag
- that contains the payload files you want- Returns:
- the directory that contains the payload files
-
getDataDir
With bagit version 2.0 (.bagit) payload files are no longer in the "data" directory. This method accounts for this and will return the directory that contains the payload files- Parameters:
version
- the bag versionoutput
- where the bag is being or was written to- Returns:
- the payload directory for the output directory
-
getBagitDir
With bagit version 2.0 (.bagit) bagit specific files are no longer at the bag root directory. This method accounts for this and will return the directory that contains the bag specific files.- Parameters:
bag
- the bag- Returns:
- the directory which contains the bag specific files, like manifests or bagit.txt
-
getBagitDir
With bagit version 2.0 (.bagit) bagit specific files are no longer at the bag root directory. This method accounts for this and will return the directory that contains the bag specific files.- Parameters:
version
- the bag versionbagRoot
- the root directory of the bag- Returns:
- the directory which contains the bag specific files, like manifests or bagit.txt
-
generatePayloadOxum
Calculate the total file and byte count of the files in the payload directory- Parameters:
dataDir
- the directory to calculate the payload-oxum- Returns:
- the string representation of the payload-oxum value
- Throws:
IOException
- if there is an error reading any of the files
-