pub struct Pkg<R: AsRef<[u8]>> { /* private fields */ }Expand description
A parsed PS4 PKG file.
This struct provides read-only access to the PKG contents including entries, headers, and the encrypted PFS image.
Reference: https://www.psdevwiki.com/ps4/PKG_files
Implementations§
Source§impl<R: AsRef<[u8]>> Pkg<R>
impl<R: AsRef<[u8]>> Pkg<R>
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Returns the number of entries in the PKG.
Sourcepub fn entries(&self) -> PkgEntries<'_> ⓘ
pub fn entries(&self) -> PkgEntries<'_> ⓘ
Returns an iterator over all entries in the PKG.
Each item contains the entry index and the entry metadata.
§Example
use orbis_pkg::Pkg;
let bytes = std::fs::read("game.pkg")?;
let pkg = Pkg::new(bytes)?;
for result in pkg.entries() {
let (index, entry) = result?;
println!("Entry {}: id=0x{:08X}, size={}", index, entry.id(), entry.data_size());
}Sourcepub fn entry_data(&self, entry: &PkgEntry) -> Result<Vec<u8>, EntryDataError>
pub fn entry_data(&self, entry: &PkgEntry) -> Result<Vec<u8>, EntryDataError>
Gets the decrypted data for an entry.
Returns the decrypted data with any padding removed.
§Errors
Returns EntryDataError::NoDecryptionKey if the entry is encrypted
and no decryption key is available for its key index.
§Example
use orbis_pkg::Pkg;
use orbis_pkg::entry::EntryId;
let bytes = std::fs::read("game.pkg")?;
let pkg = Pkg::new(bytes)?;
// Find and extract param.sfo
if let Ok((entry, _)) = pkg.find_entry(EntryId::ParamSfo) {
let data = pkg.entry_data(&entry)?;
std::fs::write("param.sfo", &data)?;
}Sourcepub fn get_pfs_image(&self) -> Option<PfsImage<'_>>
pub fn get_pfs_image(&self) -> Option<PfsImage<'_>>
Returns the embedded PFS image and its encryption key.
Returns None if the PFS offset/size is invalid.
Sourcepub fn find_entry(
&self,
id: EntryId,
) -> Result<(PkgEntry, usize), FindEntryError>
pub fn find_entry( &self, id: EntryId, ) -> Result<(PkgEntry, usize), FindEntryError>
Finds an entry by its ID.
Returns the entry and its index if found.
Sourcepub fn find_entry_raw(
&self,
id: u32,
) -> Result<(PkgEntry, usize), FindEntryError>
pub fn find_entry_raw( &self, id: u32, ) -> Result<(PkgEntry, usize), FindEntryError>
Finds an entry by its raw numeric ID.
This is useful when working with unknown/unsupported IDs.