Class FileIO
java.lang.Object
de.luckymcdev.foundryengine.util.common.FileIO
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendText(Path path, String content) static voidCopies a file, or a whole directory tree.static voidZips a directory.static voidcreateZipFromFiles(List<Path> files, Path zipPath) Zips individual files flat (by file name).static booleanDeletes a file, or a directory including its contents.static voiddeleteDirectory(Path path) static voidDownloads to a temp file next todestPathand moves it into place on success, so a failed download never leaves a partial file or destroys an existing one.static booleanTrue if a file OR directory exists atpath.static voidextractZip(Path zipPath, Path destDir) static voidextractZipDirectory(Path zipPath, String dirEntry, Path destDir) Extracts everything belowdirEntry(e.g.static PathgameDir()static booleanisDirectory(Path path) static booleanlistRecursive(Path path) Lists all regular files belowpath.static FileIO.FileMetadatastatic voidstatic byte[]static Stringstatic StringreadZipEntry(Path zipPath, String entryName) static byte[]readZipEntryBytes(Path zipPath, String entryName) static Pathstatic voidsaveZipEntry(Path zipPath, String entryName, Path destPath) Extracts a single entry todestPath.static voidwriteBytes(Path path, byte[] bytes) static void
-
Constructor Details
-
FileIO
public FileIO()
-
-
Method Details
-
gameDir
-
resolve
- Throws:
IOException
-
readText
- Throws:
IOException
-
readLines
- Throws:
IOException
-
writeText
- Throws:
IOException
-
appendText
- Throws:
IOException
-
readBytes
- Throws:
IOException
-
writeBytes
- Throws:
IOException
-
copy
Copies a file, or a whole directory tree. For directories the contents ofsourceare merged intotarget(existing files are replaced). Symbolic links inside a copied tree are skipped.- Throws:
IOException
-
delete
Deletes a file, or a directory including its contents. A symbolic link is removed without touching what it points to.- Returns:
- true if something was deleted
- Throws:
IOException
-
deleteDirectory
- Throws:
IOException
-
mkdirs
- Throws:
IOException
-
list
- Throws:
IOException
-
listRecursive
Lists all regular files belowpath.- Throws:
IOException
-
exists
True if a file OR directory exists atpath.- Throws:
IOException
-
isFile
- Throws:
IOException
-
isDirectory
- Throws:
IOException
-
metadata
- Throws:
IOException
-
createZip
Zips a directory. Empty directories are kept; the zip itself is never included.- Throws:
IOException
-
createZipFromFiles
Zips individual files flat (by file name). Two files with the same name are rejected.- Throws:
IOException
-
listZip
- Throws:
IOException
-
readZipEntry
- Throws:
IOException
-
readZipEntryBytes
- Throws:
IOException
-
extractZip
- Throws:
IOException
-
extractZipDirectory
public static void extractZipDirectory(Path zipPath, String dirEntry, Path destDir) throws IOException Extracts everything belowdirEntry(e.g. "level/") intodestDir, with thedirEntryprefix stripped. An emptydirEntryextracts the whole zip.- Throws:
IOException
-
saveZipEntry
Extracts a single entry todestPath. IfentryNamerefers to a directory ("level" or "level/"), its contents are extracted intodestPath.- Throws:
IOException
-
download
Downloads to a temp file next todestPathand moves it into place on success, so a failed download never leaves a partial file or destroys an existing one.- Throws:
IOException
-