pub struct IniFileSystem { /* private fields */ }Expand description
A hierarchical file system of IniFile.
example usage:
use std::path::PathBuf;
use rpkg_rs::misc::ini_file_system::IniFileSystem;
let retail_path = PathBuf::from("Path to retail folder");
let thumbs_path = retail_path.join("thumbs.dat");
let thumbs = IniFileSystem::from(&thumbs_path.as_path())?;
let app_options = &thumbs.root()?;
if let (Some(proj_path), Some(runtime_path)) = (app_options.get("PROJECT_PATH"), app_options.get("RUNTIME_PATH")) {
println!("Project path: {}", proj_path);
println!("Runtime path: {}", runtime_path);
}Implementations§
Source§impl IniFileSystem
impl IniFileSystem
pub fn new(ini_file: IniFile) -> Self
Sourcepub fn from_path(
root_file: impl AsRef<Path>,
xtea_config: XteaConfig,
) -> Result<Self, IniFileError>
pub fn from_path( root_file: impl AsRef<Path>, xtea_config: XteaConfig, ) -> Result<Self, IniFileError>
Loads an IniFileSystem from a root file on disk.
The file is read from root_file and decrypted using the provided
XteaConfig, parsed as an IniFile, and any !include directives
are resolved recursively relative to the root file’s parent directory.
Sourcepub fn write_to_folder<P: AsRef<Path>>(
&self,
path: P,
xtea_config: XteaConfig,
) -> Result<(), IniFileError>
pub fn write_to_folder<P: AsRef<Path>>( &self, path: P, xtea_config: XteaConfig, ) -> Result<(), IniFileError>
Writes the entire IniFileSystem to a folder on disk.
The root file and all included files are written recursively, preserving
their relative paths. Output is encrypted with the provided
XteaConfig.
If path points to a file, its parent directory is used as the export root.
If you don’t want multiple included ini files in the export path you should consider using the normalize function first first
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Normalizes the IniFileSystem by merging all included files into the root file.
Sections and console commands from included files are applied breadth-first. When an option already exists in the root, later values overwrite earlier ones. Included files are removed from the hierarchy as part of normalization.
Sourcepub fn console_cmds(&self) -> Vec<String>
pub fn console_cmds(&self) -> Vec<String>
Retrieves all console commands from the IniFileSystem, including those from included files.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IniFileSystem
impl RefUnwindSafe for IniFileSystem
impl Send for IniFileSystem
impl Sync for IniFileSystem
impl Unpin for IniFileSystem
impl UnsafeUnpin for IniFileSystem
impl UnwindSafe for IniFileSystem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.