Package com.palmergames.util
Class FileMgmt
java.lang.Object
com.palmergames.util.FileMgmt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckOrCreateFile(String filePath) Checks a filePath to see if it exists, if it doesn't it will attempt to create the file at the designated path.static booleancheckOrCreateFiles(String... files) Checks an array of folderPaths to see if they exist, if they don't it will try to create the folder at the designated paths.static booleancheckOrCreateFolder(String folderPath) Checks a folderPath to see if it exists, if it doesn't it will attempt to create the folder at the designated path.static booleancheckOrCreateFolders(String... folders) Checks an array of folderPaths to see if they exist, if they don't it will try to create the folder at the designated paths.static voidcopyDirectory(File sourceLocation, File targetLocation) static voiddeleteFile(File file) Delete file, or if path represents a directory, recursively delete it's contents beforehand.static booleandeleteOldBackups(File backupsDir, long deleteAfter) Delete child files/folders of backupsDir with a filename ending in milliseconds that is older than deleteAfter milliseconds in age.static @NotNull StringgetExtension(@NotNull Path path) static @NotNull StringgetFileName(@NotNull Path path) static Stringstatic booleanlistToFile(Collection<String> source, String targetLocation) Write a list to a file, terminating each line with a system specific new line.loadFileIntoHashMap(File file) Function which reads from a resident, town, nation, townyobject file, returning a hashmap.static voidstatic voidmoveTownBlockFile(File sourceFile, String targetLocation, String townDir) static voidrecursiveZipDirectory(File sourceFolder, ZipOutputStream zipStream) static voidsavePlotData(PlotBlockData data, File file, String path) Method to save a PlotBlockData object to disk.static voidstatic voidzipDirectories(File destination, File... sourceFolders) static voidZip a given file into the given path.
-
Constructor Details
-
FileMgmt
public FileMgmt()
-
-
Method Details
-
checkOrCreateFolder
Checks a folderPath to see if it exists, if it doesn't it will attempt to create the folder at the designated path.- Parameters:
folderPath-Stringcontaining a path to a folder.- Returns:
- True if the folder exists or if it was successfully created.
-
checkOrCreateFolders
Checks an array of folderPaths to see if they exist, if they don't it will try to create the folder at the designated paths.- Parameters:
folders- array ofStringcontaining a path to a folder.- Returns:
- true or false
-
checkOrCreateFile
Checks a filePath to see if it exists, if it doesn't it will attempt to create the file at the designated path.- Parameters:
filePath-Stringcontaining a path to a file.- Returns:
- True if the folder exists or if it was successfully created.
-
checkOrCreateFiles
Checks an array of folderPaths to see if they exist, if they don't it will try to create the folder at the designated paths.- Parameters:
files- array ofStringcontaining a path to a file.- Returns:
- true or false
-
copyDirectory
- Throws:
IOException
-
listToFile
Write a list to a file, terminating each line with a system specific new line.- Parameters:
source- - Data sourcetargetLocation- - Target location on Filesystem- Returns:
- true on success, false on IOException
-
moveFile
-
moveTownBlockFile
-
getFileTimeStamp
-
tar
- Throws:
IOException
-
zipFile
Zip a given file into the given path.- Parameters:
file- - File to zip.path- - Path to put file.
-
zipDirectories
- Throws:
IOException
-
recursiveZipDirectory
public static void recursiveZipDirectory(File sourceFolder, ZipOutputStream zipStream) throws IOException - Throws:
IOException
-
deleteFile
Delete file, or if path represents a directory, recursively delete it's contents beforehand.- Parameters:
file- -Fileto delete
-
deleteOldBackups
Delete child files/folders of backupsDir with a filename ending in milliseconds that is older than deleteAfter milliseconds in age.- Parameters:
backupsDir- -Filepath to backupsDirdeleteAfter- - Maximum age of files, in milliseconds- Returns:
- Whether old backups were successfully deleted.
-
loadFileIntoHashMap
Function which reads from a resident, town, nation, townyobject file, returning a hashmap.- Parameters:
file- - File from which the HashMap will be made.- Returns:
- HashMap - Used for loading keys and values from object files.
-
savePlotData
Method to save a PlotBlockData object to disk.- Parameters:
data- PlotBlockData object containing a plot snapshot used for the unclaim-on-revert feature.file- Directory to save the PlotBlockData to.path- Zip file location to save to.
-
getFileName
- Parameters:
path- The file path- Returns:
- The file name for the given path (minus file extension)
-
getExtension
-