pub struct Resources {
pub list: Arc<Mutex<Vec<Arc<Resource>>>>,
/* private fields */
}Expand description
Data structure representing a resource file. This data structure
points to a .res or .exe file and allows loading and modifying
resource in this file.
Fields§
§list: Arc<Mutex<Vec<Arc<Resource>>>>resources contained in the supplied file represented by the Resource data structure.
Implementations§
Source§impl Resources
impl Resources
Sourcepub fn new(file: &Path) -> Resources
pub fn new(file: &Path) -> Resources
Create new instance of the resource manager bound to a specific resource file.
Once created, the resource file should be opened using Resources::open() or Resources::load().
Sourcepub fn load(&self) -> Result<(), Error>
pub fn load(&self) -> Result<(), Error>
Load resources from the resource file. This function does not need to be called
explicitly as Resources::open will call it. It is useful if you want to load
resources for extraction purposes only.
pub fn module_handle(&self) -> Arc<Mutex<Option<HANDLE>>>
Sourcepub fn open(&mut self) -> Result<&Self, Error>
pub fn open(&mut self) -> Result<&Self, Error>
Open the resource file. This function opens a Windows handle to
the resource file and must be followed by Resources::close.
Sourcepub fn open_delete_existing_resources(&mut self) -> Result<&Self, Error>
pub fn open_delete_existing_resources(&mut self) -> Result<&Self, Error>
Opens the resource file with delete_existing_resources set to true.
This will result in retention in a deletion of previously existing resources.
Sourcepub fn remove(&self, resource: &Resource) -> Result<&Self, Error>
pub fn remove(&self, resource: &Resource) -> Result<&Self, Error>
Remove the supplied resource from the resource file.
Sourcepub fn remove_with_args(
&self,
kind: &Id,
name: &Id,
lang: u16,
) -> Result<&Self, Error>
pub fn remove_with_args( &self, kind: &Id, name: &Id, lang: u16, ) -> Result<&Self, Error>
Remove the resource from the resource file by specifying resource type, name and lang.
WARNING: If this method fails, the entire update set may fail (this is true for any API calls).
As such it is highly recommended to use Resources::remove instead and supplying and existing
Resource struct as it ensures that all supplied information is correct.
This method is provided for advanced usage only.
Sourcepub fn try_replace(&self, resource: &Resource) -> Result<&Self, Error>
pub fn try_replace(&self, resource: &Resource) -> Result<&Self, Error>
Replace (Update) the resource in the resource file. It is expected that this is the original resource with the modified raw data.
Sourcepub fn replace_with_args(
&self,
kind: &Id,
name: &Id,
lang: u16,
data: &[u8],
) -> Result<&Self, Error>
pub fn replace_with_args( &self, kind: &Id, name: &Id, lang: u16, data: &[u8], ) -> Result<&Self, Error>
Replace (Update) the resource in the resource file by supplying the resource type, name and lang
as well as a u8 slice containing the raw resource data. Please note that if this function fails
the entire resoruce update set may fail.
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Close the resource file. This applies all the changes (updates) to the resource file.
Sourcepub fn insert(&self, r: Resource)
pub fn insert(&self, r: Resource)
Create a new resource entry in the resource file. This function
expects a valid Resource structure containing an appropriate
resource type, name and raw data.
Sourcepub fn find(&self, typeid: Id, nameid: Id) -> Option<Arc<Resource>>
pub fn find(&self, typeid: Id, nameid: Id) -> Option<Arc<Resource>>
Locate a resource entry by type and name.
Sourcepub fn get_version_info(&self) -> Result<Option<VersionInfo>, Error>
pub fn get_version_info(&self) -> Result<Option<VersionInfo>, Error>
Locate and deserialize VS_VERSIONINFO structure (represented by VersionInfo).