ICryArchive

C++
struct ICryArchive : public _reference_target_t {
  enum ECompressionMethods {
    METHOD_STORE = 0,
    METHOD_COMPRESS = 8,
    METHOD_DEFLATE = 8,
    METHOD_COMPRESS_AND_ENCRYPT = 11
  };
  enum ECompressionLevels {
    LEVEL_FASTEST = 0,
    LEVEL_FASTER = 2,
    LEVEL_NORMAL = 8,
    LEVEL_BETTER = 8,
    LEVEL_BEST = 9,
    LEVEL_DEFAULT = -1
  };
  enum EPakFlags {
    FLAGS_ABSOLUTE_PATHS = 1,
    FLAGS_RELATIVE_PATHS_ONLY = 1<<1,
    FLAGS_READ_ONLY = 1<<2,
    FLAGS_OPTIMIZED_READ_ONLY = (1 << 3),
    FLAGS_CREATE_NEW = 1<<4,
    FLAGS_DONT_COMPACT = 1<<5,
    FLAGS_IN_MEMORY = BIT(6),
    FLAGS_IN_MEMORY_CPU = BIT(7),
    FLAGS_IN_MEMORY_MASK = FLAGS_IN_MEMORY|FLAGS_IN_MEMORY_CPU,
    FLAGS_FILENAMES_AS_CRC32 = BIT(8),
    FLAGS_ON_HDD = BIT(9),
    FLAGS_OVERRIDE_PAK = BIT(10),
    FLAGS_DISABLE_PAK = BIT(11)
  };
  struct IEnumerateArchiveEntries {
  };
};
File

ICryPak.h

Description

This represents one particular archive filcare.

ICryArchive::ECompressionLevels Enumeration
C++
enum ECompressionLevels {
  LEVEL_FASTEST = 0,
  LEVEL_FASTER = 2,
  LEVEL_NORMAL = 8,
  LEVEL_BETTER = 8,
  LEVEL_BEST = 9,
  LEVEL_DEFAULT = -1
};
File

ICryPak.h

Description

Compression levels

ICryArchive::ECompressionMethods Enumeration
C++
enum ECompressionMethods {
  METHOD_STORE = 0,
  METHOD_COMPRESS = 8,
  METHOD_DEFLATE = 8,
  METHOD_COMPRESS_AND_ENCRYPT = 11
};
File

ICryPak.h

Description

Compression methods

ICryArchive::EPakFlags Enumeration
C++
enum EPakFlags {
  FLAGS_ABSOLUTE_PATHS = 1,
  FLAGS_RELATIVE_PATHS_ONLY = 1<<1,
  FLAGS_READ_ONLY = 1<<2,
  FLAGS_OPTIMIZED_READ_ONLY = (1 << 3),
  FLAGS_CREATE_NEW = 1<<4,
  FLAGS_DONT_COMPACT = 1<<5,
  FLAGS_IN_MEMORY = BIT(6),
  FLAGS_IN_MEMORY_CPU = BIT(7),
  FLAGS_IN_MEMORY_MASK = FLAGS_IN_MEMORY|FLAGS_IN_MEMORY_CPU,
  FLAGS_FILENAMES_AS_CRC32 = BIT(8),
  FLAGS_ON_HDD = BIT(9),
  FLAGS_OVERRIDE_PAK = BIT(10),
  FLAGS_DISABLE_PAK = BIT(11)
};
File

ICryPak.h

Members
Members
Description
FLAGS_ABSOLUTE_PATHS = 1
support for absolute and other complex path specifications - all paths will be treated relatively to the current directory (normally MasterCD)
FLAGS_RELATIVE_PATHS_ONLY = 1<<1
if this is set, the object will only understand relative to the zip file paths, but this can give an opportunity to optimize for frequent quick accesses FLAGS_SIMPLE_RELATIVE_PATHS and FLAGS_ABSOLUTE_PATHS are mutually exclusive
FLAGS_READ_ONLY = 1<<2
if this flag is set, the archive update/remove operations will not work this is useful when you open a read-only or already opened for reading files. If FLAGS_OPEN_READ_ONLY | FLAGS_SIMPLE_RELATIVE_PATHS are set, ICryPak will try to return an object optimized for memory, with long life cycle
FLAGS_OPTIMIZED_READ_ONLY = (1 << 3)
if this flag is set, FLAGS_OPEN_READ_ONLY flags are also implied. The returned object will be optimized for quick access and memory footprint
FLAGS_CREATE_NEW = 1<<4
if this is set, the existing file (if any) will be overwritten
FLAGS_DONT_COMPACT = 1<<5
if this flag is set, and the file is opened for writing, and some files were updated so that the archive is no more continuous, the archive will nevertheless NOT be compacted upon closing the archive file. This can be faster if you open/close the archive for writing multiple times
FLAGS_IN_MEMORY = BIT(6)
flag is set when complete pak has been loaded into memory
FLAGS_FILENAMES_AS_CRC32 = BIT(8)
Store all file names as crc32 in a flat directory structure.
FLAGS_ON_HDD = BIT(9)
flag is set when pak is stored on HDD
FLAGS_OVERRIDE_PAK = BIT(10)
Override pak - paks opened with this flag go at the end of the list and contents will be found before other paks Used for patching
FLAGS_DISABLE_PAK = BIT(11)
Disable a pak file without unloading it, this flag is used in combination with patches and multiplayer to ensure that specific paks stay in the position(to keep the same priority) but beeing disabled when running multiplayer
ICryArchive::IEnumerateArchiveEntries Structure
C++
struct IEnumerateArchiveEntries {
};
File

ICryPak.h

ICryArchive::IEnumerateArchiveEntries::~IEnumerateArchiveEntries Destructor
C++
ICryArchive::IEnumerateArchiveEntries::OnEnumArchiveEntry Method
C++
virtual bool OnEnumArchiveEntry(const char* pFilename, Handle hEntry, bool bIsFolder, int aSize, int64 aModifiedTime) = 0;
ICryArchive::~ICryArchive Destructor
C++
virtual ~ICryArchive();
ICryArchive::EnumEntries Method
C++
virtual int EnumEntries(Handle hFolder, IEnumerateArchiveEntries* pEnum) = 0;
Description

enumerate the file entries found in the specified folder return the number of entries

ICryArchive::FindFile Method

Finds the file; you don't have to close the returned handle.

C++
virtual Handle FindFile(const char* szPath) = 0;
Returns

NULL if the file doesn't exist

ICryArchive::GetClassId Method

Get the class id.

C++
virtual unsigned GetClassId() const = 0;
ICryArchive::GetFileSize Method

Get the file size (uncompressed).

C++
virtual unsigned GetFileSize(Handle) = 0;
Returns

The size of the file (unpacked) by the handle

ICryArchive::GetFlags Method

Get the flags of this object.

C++
virtual unsigned GetFlags() const = 0;
Description

The possibles flags are defined in EPakFlags.

See Also
ICryArchive::GetFullPath Method

Get the full path to the archive file.

C++
virtual const char* GetFullPath() const = 0;
ICryArchive::GetMemoryUsage Method

Collect allocated memory in CrySizer

C++
virtual void GetMemoryUsage(ICrySizer * pSizer) const = 0;
ICryArchive::GetRootFolderHandle Method
C++
virtual Handle GetRootFolderHandle() = 0;
Description

Get archive's root folder

ICryArchive::IsReadOnly Method

Determines if the archive is read only.

C++
inline bool IsReadOnly() const;
Returns

true if this archive is read-only

ICryArchive::ReadFile Method

Reads the file into the preallocated buffer

C++
virtual int ReadFile(Handle, void* pBuffer) = 0;
Notes

Must be at least the size returned by GetFileSize.

ICryArchive::RemoveAll Method

Deletes all files and directories in the archive.

C++
virtual int RemoveAll() = 0;
ICryArchive::RemoveDir Method

Deletes the directory, with all its descendants (files and subdirs).

C++
virtual int RemoveDir(const char* szRelativePath) = 0;
ICryArchive::RemoveFile Method

Deletes the file from the archive.

C++
virtual int RemoveFile(const char* szRelativePath) = 0;
ICryArchive::ResetFlags Method

Resets the flags of this object.

C++
virtual bool ResetFlags(unsigned nFlagsToSet) = 0;
See Also
ICryArchive::SetFlags Method

Sets the flags of this object.

C++
virtual bool SetFlags(unsigned nFlagsToSet) = 0;
Description

The possibles flags are defined in EPakFlags.

See Also
ICryArchive::SetPackAccessible Method

Control if files in this pack can be accessed

C++
virtual bool SetPackAccessible(bool bAccessible) = 0;
Returns

true if archive state was changed

ICryArchive::StartContinuousFileUpdate Method

Adds a new file to the zip or update an existing one if it is not compressed - just stored - start a big file ( name might be misleading as if nOverwriteSeekPos is used the update is not continuous )

C++
virtual int StartContinuousFileUpdate(const char* szRelativePath, unsigned nSize) = 0;
Description

First step for the UpdateFileConinouseSegment

ICryArchive::UpdateFile Method

Adds a new file to the zip or update an existing one.

C++
virtual int UpdateFile(const char* szRelativePath, void* pUncompressed, unsigned nSize, unsigned nCompressionMethod = 0, int nCompressionLevel = -1) = 0;
Description

Adds a new file to the zip or update an existing one adds a directory (creates several nested directories if needed) compression methods supported are METHOD_STORE == 0 (store) and METHOD_DEFLATE == METHOD_COMPRESS == 8 (deflate) , compression level is LEVEL_FASTEST == 0 till LEVEL_BEST == 9 or LEVEL_DEFAULT == -1 for default (like in zlib)

ICryArchive::UpdateFileContinuousSegment Method

Adds a new file to the zip or update an existing's segment if it is not compressed - just stored adds a directory (creates several nested directories if needed) ( name might be misleading as if nOverwriteSeekPos is used the update is not continuous )

C++
virtual int UpdateFileContinuousSegment(const char* szRelativePath, unsigned nSize, void* pUncompressed, unsigned nSegmentSize, unsigned nOverwriteSeekPos = 0xffffffff) = 0;
Parameters
Parameters
Description
unsigned nOverwriteSeekPos = 0xffffffff
0xffffffff means the seek pos should not be overwritten (then it needs UpdateFileCRC() to update CRC)
ICryArchive::UpdateFileCRC Method

needed to update CRC if UpdateFileContinuousSegment() was used with nOverwriteSeekPos

C++
virtual int UpdateFileCRC(const char* szRelativePath, const uint32 dwCRC) = 0;
ICryArchive::Handle Nested Type
C++
typedef void* Handle;