FileUtils
This is a helper class to handle file operations in a platform agnostic way.
Enumerations
enum OS_ID:
WINDOWS - Windows or UWP
MACOS - macOS
LINUX - Unix systems (Linux, BSD, etc.)
UNSUPPORTED - Any other system currently not supported
Methods
Type |
Name |
|---|---|
void |
|
Tests whether the supplied path(s) exist in the user’s system. If paths is a String, tests if it exists. Otherwise, if it is a Array, tests for all strings inside and returns the first valid one. Returns "" if no valid path is found.
void ensure_path (path: String)
Recursively creates the directory structure of the specified path, ensuring all subfolders exist
# Creates the directory structure "very/long/folder" if necessary
FileUtils.ensure_path("very/long/folder/my_file.txt")
var file = File.open("very/long/folder/my_file.txt", File.WRITE)
...
Expand paths with embedded variables. Supported variables are:
~- User’s home directory
# Returns C:/Users/<username>/Documents on Windows
FileUtils.expand_path("~/Documents")
int get_space_left ()
Returns the amount of free space, in bytes, of the disk that contains RetroHub’s config directory.
Returns the total size of the specified folder, in bytes. If filter_folders is specified, it will not count the size of any folder that matches any of the strings in the array.
Returns the total number of files in the specified folder. If filter_folders is specified, it will not count any files inside a folder that matches any of the strings in the array.
String get_home_dir ()
Returns the user’s home directory.
OS_ID get_os_id ()
Returns the current operating system as an OS_ID.
String get_os_string ()
Returns the current operating system as a string. Possible values are "windows", "macos", "linux", and "null".
bool is_steam_deck ()
Returns true if the current system is a Steam Deck.