PackageFile.pkg 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. $#include "PackageFile.h"
  2. /// %File entry within the package file.
  3. struct PackageEntry
  4. {
  5. /// Offset from the beginning.
  6. unsigned offset_;
  7. /// File size.
  8. unsigned size_;
  9. /// File checksum.
  10. unsigned checksum_;
  11. };
  12. /// Stores files of a directory tree sequentially for convenient access.
  13. class PackageFile : public Object
  14. {
  15. public:
  16. /// Open the package file. Return true if successful.
  17. bool Open(const String& fileName);
  18. /// Check if a file exists within the package file.
  19. bool Exists(const String& fileName) const;
  20. /// Return the file entry corresponding to the name, or null if not found.
  21. const PackageEntry* GetEntry(const String& fileName) const;
  22. /// Return the package file name.
  23. const String& GetName() const { return fileName_; }
  24. /// Return hash of the package file name.
  25. StringHash GetNameHash() const { return nameHash_; }
  26. /// Return number of files.
  27. unsigned GetNumFiles() const { return entries_.Size(); }
  28. /// Return total size of the package file.
  29. unsigned GetTotalSize() const { return totalSize_; }
  30. /// Return checksum of the package file contents.
  31. unsigned GetChecksum() const { return checksum_; }
  32. };