Package rosequartz.files
Class FileManager
java.lang.Object
rosequartz.files.FileManager
Used to create files completely independent of the platform.
There is no working directory, the working directory is always the root,
and all paths provided must be relative to the root.
Keep in mind that different browsers set different limitations on how much data
your game can store, with 2.5MB, 5MB and 10MB being popular values.
Projects targeting the web should try to keep their file sizes as low as possible.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringMakes sure that the given string is formatted in a way that the runtimes can work with.voidCopies a file to the given file path, replacing if already exists and copying file attributes.voiddeleteFile(String path)Deletes a file at the given file path.String[]directoriesIn(String directory)Gets an array containing all directories in a given directory, excluding files.booleanfileExists(String path)Gets if a given file path exists.String[]Gets an array containing all files in a given directory, excluding directories.static FileManagerget()Gets the file manager.voidMoves a file to the given file path.String[]Gets an array containing all directories and files in a given directory.byte[]readFileBytes(String path)Reads an array of bytes from the given file path.readFileObject(String path)Reads an object from the given file path.readFileString(String path)Reads a string from the given file path.voidwriteFileBytes(String path, byte[] data)Writes the given array of bytes to the given file path.voidwriteFileObject(String path, Serializable data)Writes the given object to the given file path.voidwriteFileString(String path, String data)Writes the given string to the given file path.
-
Constructor Details
-
FileManager
-
-
Method Details
-
get
Gets the file manager.- Returns:
- FileManager-object
- See Also:
FileManager
-
_process
Makes sure that the given string is formatted in a way that the runtimes can work with.- Parameters:
path- path to format- Returns:
- formatted path
-
fileExists
Gets if a given file path exists.- Parameters:
path- the path of the file to check for- Returns:
- if the file exists
-
filesIn
Gets an array containing all files in a given directory, excluding directories.- Parameters:
directory- directory the files have to be in- Returns:
- list of all files in a directory
-
directoriesIn
Gets an array containing all directories in a given directory, excluding files.- Parameters:
directory- directory the directories have to be a direct child of- Returns:
- list of all directories in a directory
-
pathsIn
Gets an array containing all directories and files in a given directory.- Parameters:
directory- directory the directories and files have to be in- Returns:
- list of all directories and files in a directory
-
writeFileObject
Writes the given object to the given file path. WARNING! Writing objects is not supported by the browser runtime. The browser-runtime will throw a 'PlatformSpecificUnsupportedException'.- Parameters:
path- the path of the file to write todata- the serializable object to write- Throws:
PlatformSpecificUnsupportedException- if called in browser build target
-
writeFileBytes
Writes the given array of bytes to the given file path.- Parameters:
path- the path of the file to write todata- the array of bytes to write
-
writeFileString
Writes the given string to the given file path.- Parameters:
path- the path of the file to write todata- the string to write
-
readFileObject
Reads an object from the given file path. WARNING! Reading objects is not supported by the browser runtime. The browser-runtime will throw a 'PlatformSpecificUnsupportedException'.- Parameters:
path- the path to read from- Returns:
- the read object
- Throws:
PlatformSpecificUnsupportedException- if called in browser build target
-
readFileBytes
Reads an array of bytes from the given file path.- Parameters:
path- the path to read from- Returns:
- the read array of bytes
-
readFileString
Reads a string from the given file path.- Parameters:
path- the path to read from- Returns:
- the read string
-
deleteFile
Deletes a file at the given file path.- Parameters:
path- the path to delete
-
copyFile
Copies a file to the given file path, replacing if already exists and copying file attributes.- Parameters:
src- path of the file to copydest- path of the copy of the file
-
moveFile
Moves a file to the given file path.- Parameters:
src- path of the file to movedest- new path of the moved file
-