pub struct Content {}Expand description
The Content is a static struct that manages file searching,
loading and other operations related to resources.
Implementations§
Source§impl Content
impl Content
Sourcepub fn set_search_paths(val: &Vec<&str>)
pub fn set_search_paths(val: &Vec<&str>)
Sets an array of directories to search for resource files.
Sourcepub fn get_search_paths() -> Vec<String>
pub fn get_search_paths() -> Vec<String>
Gets an array of directories to search for resource files.
Sourcepub fn set_asset_path(val: &str)
pub fn set_asset_path(val: &str)
Sets the path to the directory containing read-only resources. Can only be altered by the user on platform Windows, MacOS and Linux.
Sourcepub fn get_asset_path() -> String
pub fn get_asset_path() -> String
Gets the path to the directory containing read-only resources. Can only be altered by the user on platform Windows, MacOS and Linux.
Sourcepub fn set_writable_path(val: &str)
pub fn set_writable_path(val: &str)
Sets the path to the directory where files can be written. Can only be altered by the user on platform Windows, MacOS and Linux. Default is the same as appPath.
Sourcepub fn get_writable_path() -> String
pub fn get_writable_path() -> String
Gets the path to the directory where files can be written. Can only be altered by the user on platform Windows, MacOS and Linux. Default is the same as appPath.
Sourcepub fn get_app_path() -> String
pub fn get_app_path() -> String
Gets the path to the directory for the application storage.
Sourcepub fn is_absolute_path(path: &str) -> bool
pub fn is_absolute_path(path: &str) -> bool
Sourcepub fn copy(src: &str, dst: &str) -> bool
pub fn copy(src: &str, dst: &str) -> bool
Copies the file or directory at the specified source path to the target path.
§Arguments
src_path- The path of the file or directory to copy.dst_path- The path to copy the file or directory to.
§Returns
bool-trueif the file or directory was successfully copied to the target path,falseotherwise.
Sourcepub fn move_to(src: &str, dst: &str) -> bool
pub fn move_to(src: &str, dst: &str) -> bool
Moves the file or directory at the specified source path to the target path.
§Arguments
src_path- The path of the file or directory to move.dst_path- The path to move the file or directory to.
§Returns
bool-trueif the file or directory was successfully moved to the target path,falseotherwise.
Sourcepub fn get_full_path(filename: &str) -> String
pub fn get_full_path(filename: &str) -> String
Sourcepub fn add_search_path(path: &str)
pub fn add_search_path(path: &str)
Sourcepub fn insert_search_path(index: i32, path: &str)
pub fn insert_search_path(index: i32, path: &str)
Inserts a search path at the specified index.
§Arguments
index- The index at which to insert the search path.path- The search path to insert.
Sourcepub fn remove_search_path(path: &str)
pub fn remove_search_path(path: &str)
Sourcepub fn clear_path_cache()
pub fn clear_path_cache()
Clears the search path cache of the map of relative paths to full paths.
Sourcepub fn get_all_files(path: &str) -> Vec<String>
pub fn get_all_files(path: &str) -> Vec<String>
Sourcepub fn copy_async(
src_file: &str,
target_file: &str,
callback: Box<dyn FnMut(bool)>,
)
pub fn copy_async( src_file: &str, target_file: &str, callback: Box<dyn FnMut(bool)>, )
Asynchronously copies a file or a folder from the source path to the destination path.
§Arguments
srcFile- The path of the file or folder to copy.targetFile- The destination path of the copied files.callback- The function to call with a boolean indicating whether the file or folder was copied successfully.
§Returns
bool-trueif the file or folder was copied successfully,falseotherwise.
Sourcepub fn save_async(filename: &str, content: &str, callback: Box<dyn FnMut(bool)>)
pub fn save_async(filename: &str, content: &str, callback: Box<dyn FnMut(bool)>)
Asynchronously saves the specified content to a file with the specified filename.
§Arguments
filename- The name of the file to save.content- The content to save to the file.callback- The function to call with a boolean indicating whether the content was saved successfully.
§Returns
bool-trueif the content was saved successfully,falseotherwise.
Sourcepub fn zip_async(
folder_path: &str,
zip_file: &str,
filter: Box<dyn FnMut(&str) -> bool>,
callback: Box<dyn FnMut(bool)>,
)
pub fn zip_async( folder_path: &str, zip_file: &str, filter: Box<dyn FnMut(&str) -> bool>, callback: Box<dyn FnMut(bool)>, )
Asynchronously compresses the specified folder to a ZIP archive with the specified filename.
§Arguments
folder_path- The path of the folder to compress, should be under the asset writable path.zip_file- The name of the ZIP archive to create.filter- An optional function to filter the files to include in the archive. The function takes a filename as input and returns a boolean indicating whether to include the file. If not provided, all files will be included.callback- The function to call with a boolean indicating whether the folder was compressed successfully.
§Returns
bool-trueif the folder was compressed successfully,falseotherwise.
Sourcepub fn unzip_async(
zip_file: &str,
folder_path: &str,
filter: Box<dyn FnMut(&str) -> bool>,
callback: Box<dyn FnMut(bool)>,
)
pub fn unzip_async( zip_file: &str, folder_path: &str, filter: Box<dyn FnMut(&str) -> bool>, callback: Box<dyn FnMut(bool)>, )
Asynchronously decompresses a ZIP archive to the specified folder.
§Arguments
zip_file- The name of the ZIP archive to decompress, should be a file under the asset writable path.folder_path- The path of the folder to decompress to, should be under the asset writable path.filter- An optional function to filter the files to include in the archive. The function takes a filename as input and returns a boolean indicating whether to include the file. If not provided, all files will be included.callback- The function to call with a boolean indicating whether the archive was decompressed successfully.
§Returns
bool-trueif the folder was decompressed successfully,falseotherwise.