Module dbpf
Source
Read and write Database Packed File (DBPF) archives.
See Also
- DBPF (SC4D Encyclopedia)
 - List of File Formats (SC4D Encyclopedia)
 
License
MIT License
Members
- 
  
isValidDbpfVersionenum auto isValidDbpfVersion(float V);Determines whether
Vis a valid DBPF version number.See Also
VersionRemarks
1.0seen in SimCity 4, The Sims 21.1seen in The Sims 22.0seen in Spore, The Sims 33.0seen in SimCity (2013)
 - 
  
Headerstruct Header(float V = 1) if (isValidDbpfVersion!V);Parameters
V
DBPF archive version. SeeVersion.See Also
DBPF Header (SC4D Encyclopedia)
- 
  
identifierstatic const identifier;Always
DBPF. - 
  
magicubyte[4] magic;Always
DBPF. - 
  
version_Version version_; - 
  
unknown1uint unknown1;Unused, possibly reserved.
 - 
  
unknown2uint unknown2;Unused, possibly reserved.
 - 
  
unknown3const uint unknown3;Should always be zero in DBPF v
2.0. - 
  
dateCreateduint dateCreated;Date created. Unix timestamp.
Remarks
Unused in DBPF1.1. - 
  
dateModifieduint dateModified;Date modified. Unix timestamp.
Remarks
Unused in DBPF v1.1. - 
  
indexMajorVersionuint indexMajorVersion;Major version of the Index table.
Remarks
Always7in The Sims 2 and SimCity 4. If this is a DBPF v2.0archive, then it is0for Spore.See Also
indexMinorVersion - 
  
indexEntryCountuint indexEntryCount;Number of entries in the Index Table.
 - 
  
indexOffsetuint indexOffset;Offset to Index table, in bytes. Location of first index entry.
 - 
  
indexSizeuint indexSize;Size of the Index table, in bytes.
 - 
  
holeEntryCountuint holeEntryCount;Number of Hole entries in the Hole Record.
 - 
  
holeOffsetuint holeOffset;Location of the hole Record.
 - 
  
holeSizeuint holeSize;Size of the hole Record, in bytes.
 - 
  
indexMinorVersionuint indexMinorVersion;Minor version of the Index table.
Remarks
In The Sims 2 for DBPF v
1.1+.In DBPF >= v
2.0, this is3, otherwise:1= v7.02= v7.1
See Also
indexMajorVersion - 
  
indexOffsetuint indexOffset;Offset to Index table, in bytes. Location of first index entry.
 - 
  
unknown4uint unknown4; - 
  
reservedubyte[24] reserved;Reserved for future use.
 - 
  
indexVersionconst @property Version indexVersion();Computed, human-readable Index table version.
 
 - 
  
Versionstruct Version;Remarks
For DBPF version specifiers:1.0seen in SimCity 4, The Sims 21.1seen in The Sims 22.0seen in Spore, The Sims 33.0seen in SimCity(2013)
7.0seen in SimCity 4, The Sims 27.1seen in The Sims 2
- 
  
simCity4static const float simCity4;
static const float sc4; - 
  
sims2static const float sims2; - 
  
sporestatic const float spore; - 
  
sims3static const float sims3; - 
  
simCitystatic const float simCity;SimCity (2013)
 - 
  
simCity4Indexstatic const Version simCity4Index; - 
  
sc4Indexstatic const Version sc4Index; - 
  
majoruint major; - 
  
minoruint minor; 
 - 
  
isValidIndexVersionenum auto isValidIndexVersion(float V);Determines whether
Vis a valid DBPF Index table version number.See Also
Version - 
  
Entrystruct Entry;
struct ResourceEntry;Index Tables list the contents of a DBPF package.
Remarks
The index table is very similar to the directory file (DIR) within a DPBF package. The difference being that the Index Table lists every file in the package, whereas the directory file only lists the compressed files within the package. Reader presents a directory file that is a mashup of these two entities, listing every file in the package, as well as indicating whether or not that particular file is compressed.See Also
DBPF Index Table (SC4D Encyclopedia)
 - 
  
TableEntryalias TableEntry = std.sumtype.SumType!(Entry, ResourceEntry).SumType; - 
  
Tablealias Table = SumType!(Entry, ResourceEntry)[]; - 
  
EntryFilteralias EntryFilter = bool function(SumType!(Entry, ResourceEntry) entry); - 
  
entryOfbool entryOf(alias T)(TableEntryentry) if (is(typeof(T) == Tgi) || is(typeof(T.asOriginalType) == Tgi)); - 
  
HoleTablestruct HoleTable;A Hole Table contains the location and size of all holes in a DBPF file.
Remarks
Holes are created when the game deletes something from a DBPF. The holes themselves are simply junk data of the appropriate length to fill the hole. - 
  
FileHeaderstruct FileHeader;Occurs before
File.contents, if and only if theFileis compressed.- 
  
compressedSizeuint compressedSize;Compressed size of the file, in bytes.
 - 
  
compressionIdconst ushort compressionId;Compression ID, i.e. (
0x10FB). Always QFS Compression.See Also
DBPF Compression (SC4D Encyclopedia)
 - 
  
uncompressedSizeint24 uncompressedSize;Uncompressed size of the file, in bytes.
 
 - 
  
Filestruct File(Flag!"compressed" Compressed = false);
alias UncompressedFile = File!Flag.no.File;
alias CompressedFile = File!Flag.yes.File;Files fill the bulk of a DBPF archive.
A file header exists only if this file is compressed.
Remarks
Each file is either uncompressed or compressed. To check if a file is compressed you first need to read the DIR file, if it exists. If no DIR entry exists, then no files within the package are compressed.- 
  
headerFileHeader header;Exists only if this file is compressed.
 - 
  
contentsubyte[] contents;Contents of this file.
See List of File Formats for a list of the file types that may exist within a DBPF archive.
 - 
  
sizeconst @property uint size();Uncompressed size of this file, in bytes.
 
 - 
  
ArchiveExceptionclass ArchiveException: object.Exception;Thrown when an
Archiveis invalid or corrupt. - 
  
isValidVersionenum auto isValidVersion(float DBPF, float V);Determines whether
DBPF andV` are valid DBPF and Index table versions.See Also
isValidDbpfVersionisValidIndexVersionVersion
 - 
  
Archivestruct Archive(float DBPF) if (isValidDbpfVersion!DBPF);- 
  
pathconst string path; - 
  
metadataHead metadata; - 
  
entriesTable entries; - 
  
directoryconst UncompressedFile* directory;If no DIR entry exists, then no files within the package are compressed.
 - 
  
thisthis(stringpath);Open a DBPF archive from the given file
.pathThrows
FileExceptionwhen the archive is not found, or there is some I/O error.Throws
ArchiveExceptionwhen the archive is invalid or corrupt. - 
  
closevoid close(); 
 - 
  
SimCity4Archivealias SimCity4Archive = Archive!1.0F.Archive; - 
  
Sims2Archivealias Sims2Archive = Archive!1.1F.Archive; - 
  
SporeArchivealias SporeArchive = Archive!2.0F.Archive; - 
  
Sims3Archivealias Sims3Archive = Archive!2.0F.Archive; - 
  
SimCity2013Archivealias SimCity2013Archive = Archive!3.0F.Archive;