![]() |
CRM64Pro GDK v0.13.0
A free cross-platform game development kit built on top of SDL 3.0
|
Archive Manager and Archive objects for managing CDC data container files [v25.12.0].
The Archive module provides management for CDC (CRM64Pro Data Container) files through the Archive Manager and Archive objects. CDC is an extensible and open data container format based on data blocks, designed specifically for CRM64Pro GDK as the successor to the old DPF format developed for CRM32Pro SDK.
The CDC format defines a minimal 8-byte magic header containing the implementation version and a set of interface methods. The format is designed to be extensible, allowing different implementations.
| Magic header | 8 bytes containing CDC implementation version |
|---|---|
| Block identification | Blocks identified by type (cannot start with "?SD_") and name (cannot start with "#") |
| Maximum file size | 4GB |
Currently, the only available implementation is CDCv1.1 with the following features:
| Header | 256 bytes for storing copyright, creation and modification dates, etc. |
|---|---|
| Index | Variable size index (minimum 128 blocks) for fast operations |
| Integrity | Detects IO data corruption and file tampering |
| Storage modes | Raw, compressed (zlib) or encrypted (AES-256) |
| Archive security | AES-256 index encryption with 4-32 byte key |
File operations
| load() | Load CDC file with IO data corruption check |
|---|---|
| save() | Save CDC file (automatically called after successful block addition) |
| defrag() | Physically delete soft-deleted blocks, remove fragmentation and resize maximum blocks |
| getFragmentation() | Get fragmentation level caused by soft deletions and overwrites |
Block operations
| blockAdd() | Add new block: skips if identical exists, overwrites payload if fits, or adds new |
|---|---|
| blockAddFile() | Add file as block with type "C64_FILE" and name as [directory]+filename+[extension] |
| blockLoad() | Load block data (soft-deleted blocks are not loaded) |
| blockSearch() | Search for block (extremely fast due to fixed index) |
| blockAt() | Access block by index (extremely fast due to fixed index) |
| blockDelete() | Soft-delete block (remains physically present but not loadable) |
| blockUndelete() | Recover a soft-deleted block |
| getNumberOfBlocks() | Get total number of data blocks |
Security operations
| secure() | Encrypt index with AES-256 to prevent block access without password |
|---|---|
| unSecure() | Decrypt index with valid password (password is unrecoverable if lost) |
This is a sharing manager: it shares a CDC ID among multiple owners when they request to open an already opened file based on the file path [directory]+file+[extension] as the key. The CDC is effectively closed only when the last owner closes it.
Classes | |
| class | CRM64Pro::Archive |
| Archive Object class. More... | |
| class | CRM64Pro::ArchiveMgr |
| Archive Manager class. More... | |
Macros | |
| #define | CDCv1_sPARAM1 64 |
| #define | CDCv1_sPARAM2 16 |
Enumerations | |
| enum | CRM64Pro::eArchiveBlockStore { CRM64Pro::ABS_RAW = 1 , CRM64Pro::ABS_COMPRESSED = 2 , CRM64Pro::ABS_CRYPTED = 3 } |
| Archive block storing method. More... | |
Functions | |
| Sint32 | CRM64Pro::Archive::info (Sint32 iMode=0) |
| Request CDC object information. | |
| Sint32 | CRM64Pro::Archive::getName (string &sName) |
| Get the name. | |
| Uint32 | CRM64Pro::Archive::getID () |
| Get the ID. | |
| Sint32 | CRM64Pro::Archive::blockAdd (Block &myBlock) |
| Add a data block. | |
| Sint32 | CRM64Pro::Archive::blockAddFile (const string &sFile, eArchiveBlockStore eABS=ABS_COMPRESSED) |
| Add a file. | |
| Sint32 | CRM64Pro::Archive::blockDelete (Block &myBlock) |
| Delete a data block. | |
| Sint32 | CRM64Pro::Archive::blockUndelete (Uint32 iBlock, Block &myBlock) |
| Recover a deleted data block. | |
| Sint32 | CRM64Pro::Archive::blockSearch (Block &myBlock) |
| Search for a given data block. | |
| Sint32 | CRM64Pro::Archive::blockAt (Uint32 iBlock, Block &myBlock) |
| Access to the given data block position. | |
| Sint32 | CRM64Pro::Archive::blockLoad (Block &myBlock) |
| Load a data block. | |
| Sint32 | CRM64Pro::Archive::blockLoadReleaseData (Block &myBlock) |
| Free a loaded data block. | |
| Uint32 | CRM64Pro::Archive::getUsedBlocks () |
| Get the number of used data blocks. | |
| Uint32 | CRM64Pro::Archive::getMaxBlocks () |
| Get the number of maximum data blocks. | |
| float | CRM64Pro::Archive::getFragmentation () |
| Get the fragmentation. | |
| Sint32 | CRM64Pro::Archive::secure (const unsigned char *myKey, Uint32 iKeySize) |
| Secure the CDC. | |
| Sint32 | CRM64Pro::Archive::unSecure () |
| Unsecure a CDC file. | |
| Sint32 | CRM64Pro::ArchiveMgr::info (Sint32 iMode=0) |
| Request Archive Manager information. | |
| Sint32 | CRM64Pro::ArchiveMgr::create (const string &sFile, Uint32 iNumBlocks=0) |
| Create a new CDC file. | |
| Sint32 | CRM64Pro::ArchiveMgr::close (Sint32 idCDC) |
| Close and destroy a CDC. | |
| Sint32 | CRM64Pro::ArchiveMgr::getNum () const |
| Get number of loaded objects. | |
| Sint32 | CRM64Pro::ArchiveMgr::setName (Sint32, const string &) |
| This method is not implemented. | |
| Archive * | CRM64Pro::ArchiveMgr::get (Sint32 idCDC=0) |
| Get a pointer to the CDC using its handler. | |
| Sint32 | CRM64Pro::ArchiveMgr::defrag (const string &sFile, Uint32 iNumBlocks=0) |
| Defragment a CDC file. | |
| Sint32 | CRM64Pro::ArchiveMgr::load (const string &sFile, const unsigned char *myKey=nullptr, Uint32 iKeySize=0) |
| Load a CDC file. | |
| Sint32 | CRM64Pro::CursorMgr::info (Sint32 iMode=0) |
| Request Cursor Manager information. | |
| Sint32 | CRM64Pro::CursorMgr::create (const string &sName, Uint32 iVersion=10) |
| Create a new cursor. | |
| Sint32 | CRM64Pro::CursorMgr::close (Sint32 idCur) |
| Close and destroy a cursor. | |
| Sint32 | CRM64Pro::CursorMgr::getNum () const |
| Get number of loaded objects. | |
| Sint32 | CRM64Pro::CursorMgr::setName (Sint32 idCur, const string &sName) |
| Change the object name. | |
| Cursor * | CRM64Pro::CursorMgr::get (Sint32 idCur) |
| Get a pointer to the cursor using its handler. | |
| Sint32 | CRM64Pro::CursorMgr::select (Sint32 idCur) |
| Select a mouse cursor. | |
| Sint32 | CRM64Pro::CursorMgr::getSelect () |
| Get selected mouse cursor. | |
| Sint32 | CRM64Pro::CursorMgr::show () |
| Make visible the selected mouse cursor. | |
| Sint32 | CRM64Pro::CursorMgr::hide () |
| Hide the mouse cursor. | |
| Sint32 | CRM64Pro::CursorMgr::status () |
| Get the cursor status. | |
| Sint32 | CRM64Pro::CursorMgr::setPosition (float fX, float fY, Sint32 idScreen=0) |
| Set the mouse cursor position. | |
| Sint32 | CRM64Pro::CursorMgr::getPosition (float *fX, float *fY) |
| Get the mouse cursor position. | |
| Sint32 | CRM64Pro::CursorMgr::getButtons () |
| Get the mouse buttons. | |
| Sint32 | CRM64Pro::CursorMgr::getButtonsPrev () |
| Get the previous mouse buttons. | |
| Sint32 | CRM64Pro::CursorMgr::getFocus () |
| Get the Screen id which currently has mouse focus. | |
| Sint32 | CRM64Pro::CursorMgr::child (Sint32 idCur) |
| Create a child cursor dependant on the provided one(the parent). | |
| Sint32 | CRM64Pro::CursorMgr::load (const string &sFileCDC, const string &sName) |
| Load a cursor stored in a CDC file. | |
| Sint32 | CRM64Pro::CursorMgr::load (const Sint32 idCDC, const string &sName) |
| Load a cursor stored in a CDC file. | |
| Sint32 | CRM64Pro::CursorMgr::remove (Sint32 idCDC, const string &sName) |
| Remove a cursor stored in a CDC file. | |
| #define CDCv1_sPARAM1 64 |
CDC v1.x: size of custom char array attribute 1
| #define CDCv1_sPARAM2 16 |
CDC v1.x: size of custom char array attribute 2
Archive block storing method.
| Enumerator | |
|---|---|
| ABS_RAW | Store block in raw form. |
| ABS_COMPRESSED | Store block compressed. |
| ABS_CRYPTED | Store block encrypted. |
| Sint32 CRM64Pro::Archive::info | ( | Sint32 | iMode = 0 | ) |
Request CDC object information.
Writes information to the default log.
| iMode | unused for the time being. |
| Sint32 CRM64Pro::Archive::getName | ( | string & | sName | ) |
Get the name.
| sName | a string reference filled in with the [directory] and the file name plus the .cdc extension. |
| Uint32 CRM64Pro::Archive::getID | ( | ) |
Get the ID.
| Sint32 CRM64Pro::Archive::blockAdd | ( | Block & | myBlock | ) |
Add a data block.
| myBlock | filled Block struct, at least it needs pData and iSize. Custom attributes depend on CDC version. |
| Sint32 CRM64Pro::Archive::blockAddFile | ( | const string & | sFile, |
| eArchiveBlockStore | eABS = ABS_COMPRESSED ) |
Add a file.
| sFile | string containing the [directory]+filename+[extension] to be added. Directory separators '\' and '/' are supported. |
| eABS | Check eArchiveBlockStore enum for details. Default is ABS_COMPRESSED. |
| Sint32 CRM64Pro::Archive::blockDelete | ( | Block & | myBlock | ) |
Delete a data block.
| myBlock | filled Block struct with custom attributes depending on CDC version. |
| Sint32 CRM64Pro::Archive::blockUndelete | ( | Uint32 | iBlock, |
| Block & | myBlock ) |
Recover a deleted data block.
| iBlock | block index position from [0 to used_blocks - 1] which contains a deleted data block. Use getUsedBlocks() for getting used_blocks. |
| myBlock | filled Block struct with custom attributes depending on CDC version. pData must be nullptr. If recovered, myBlock will contain all attributes except pData. |
| Sint32 CRM64Pro::Archive::blockSearch | ( | Block & | myBlock | ) |
Search for a given data block.
| myBlock | filled Block struct with custom attributes depending on CDC version. If found, myBlock will contain all attributes except pData. |
| Sint32 CRM64Pro::Archive::blockAt | ( | Uint32 | iBlock, |
| Block & | myBlock ) |
Access to the given data block position.
| iBlock | block index position from [0 to used_blocks - 1]. Use getUsedBlocks() for the used_blocks value. |
| myBlock | if the block index position is found, myBlock will contain all attributes except pData. |
| Sint32 CRM64Pro::Archive::blockLoad | ( | Block & | myBlock | ) |
Load a data block.
| myBlock | filled Block struct with custom attributes depending on CDC version. pData must be nullptr. If found, myBlock will contain all attributes plus the pData loaded. |
| Sint32 CRM64Pro::Archive::blockLoadReleaseData | ( | Block & | myBlock | ) |
Free a loaded data block.
| myBlock | Block struct with pData loaded by blockLoad() method. |
| Uint32 CRM64Pro::Archive::getUsedBlocks | ( | ) |
Get the number of used data blocks.
| Uint32 CRM64Pro::Archive::getMaxBlocks | ( | ) |
Get the number of maximum data blocks.
| float CRM64Pro::Archive::getFragmentation | ( | ) |
Get the fragmentation.
| Sint32 CRM64Pro::Archive::secure | ( | const unsigned char * | myKey, |
| Uint32 | iKeySize ) |
Secure the CDC.
| myKey | unsigned char array of iKeySize containing the key. |
| iKeySize | the key size in bytes. For CDC v1.1, the key size must be from 4 to 32 bytes. |
| Sint32 CRM64Pro::Archive::unSecure | ( | ) |
Unsecure a CDC file.
| Sint32 CRM64Pro::ArchiveMgr::info | ( | Sint32 | iMode = 0 | ) |
Request Archive Manager information.
Writes information to the default log.
| iMode | -1 for displaying only Manager information. 0 (default) for displaying Manager and all Objects information. A positive CDC id for displaying Manager and that specific CDC information. |
| Sint32 CRM64Pro::ArchiveMgr::create | ( | const string & | sFile, |
| Uint32 | iNumBlocks = 0 ) |
Create a new CDC file.
| sFile | string containing [directory]+filename+[extension]. The .cdc extension is added automatically if missing. Directory separators '\' and '/' are supported. |
| iNumBlocks | Maximum number of data blocks. The minimum is 64. |
| Sint32 CRM64Pro::ArchiveMgr::close | ( | Sint32 | idCDC | ) |
Close and destroy a CDC.
| idCDC | 0 for closing all CDC files, or a specific CDC id. If the CDC is shared, it will not be removed until the last owner calls this method. |
| Sint32 CRM64Pro::ArchiveMgr::getNum | ( | ) | const |
Get number of loaded objects.
| Sint32 CRM64Pro::ArchiveMgr::setName | ( | Sint32 | idCDC, |
| const string & | sName ) |
This method is not implemented.
| idCDC | Unused |
| sName | Unused |
| Archive * CRM64Pro::ArchiveMgr::get | ( | Sint32 | idCDC = 0 | ) |
Get a pointer to the CDC using its handler.
By default it returns the first CDC loaded.
| idCDC | CDC id. |
| Sint32 CRM64Pro::ArchiveMgr::defrag | ( | const string & | sFile, |
| Uint32 | iNumBlocks = 0 ) |
Defragment a CDC file.
| sFile | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
| iNumBlocks | Maximum number of data blocks (minimum 64). Default 0 keeps current max block number. Can be used to resize the maximum number of data blocks. |
| Sint32 CRM64Pro::ArchiveMgr::load | ( | const string & | sFile, |
| const unsigned char * | myKey = nullptr, | ||
| Uint32 | iKeySize = 0 ) |
Load a CDC file.
The Archive Manager shares ids based on file path as the key, so it checks if a CDC is already loaded before creating a new one.
| sFile | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
| myKey | unsigned char array containing the key. Only used for secured CDC files. Default nullptr. |
| iKeySize | key size from 4 to 32 bytes. 0 for unsecured CDC (default). |
| Sint32 CRM64Pro::CursorMgr::info | ( | Sint32 | iMode = 0 | ) |
| Sint32 CRM64Pro::CursorMgr::create | ( | const string & | sName, |
| Uint32 | iVersion = 10 ) |
Create a new cursor.
Creates an empty cursor (no image). Use Cursor::assignImage() to assign an image.
| sName | The cursor name (e.g. 'myCursor'). Must be unique, max 64 characters. |
| iVersion | Cursor version. 10 means v1.0 (only version supported). Default v1.0. |
| Sint32 CRM64Pro::CursorMgr::close | ( | Sint32 | idCur | ) |
Close and destroy a cursor.
| idCur | 0 for closing all cursors, or specific Cursor id. Stand-alone and child cursors can be closed; parent cursors cannot while they have children. |
| Sint32 CRM64Pro::CursorMgr::getNum | ( | ) | const |
Get number of loaded objects.
| Sint32 CRM64Pro::CursorMgr::setName | ( | Sint32 | idCur, |
| const string & | sName ) |
| Cursor * CRM64Pro::CursorMgr::get | ( | Sint32 | idCur | ) |
Get a pointer to the cursor using its handler.
| idCur | Cursor id. |
| Sint32 CRM64Pro::CursorMgr::select | ( | Sint32 | idCur | ) |
Select a mouse cursor.
| idCur | Cursor id. It also supports any SDL_SystemCursor. |
| Sint32 CRM64Pro::CursorMgr::getSelect | ( | ) |
Get selected mouse cursor.
| Sint32 CRM64Pro::CursorMgr::show | ( | ) |
Make visible the selected mouse cursor.
| Sint32 CRM64Pro::CursorMgr::hide | ( | ) |
Hide the mouse cursor.
| Sint32 CRM64Pro::CursorMgr::status | ( | ) |
Get the cursor status.
| Sint32 CRM64Pro::CursorMgr::setPosition | ( | float | fX, |
| float | fY, | ||
| Sint32 | idScreen = 0 ) |
Set the mouse cursor position.
| fX | float with x position. |
| fY | float with y position. |
| idScreen | Screen id. Default 0 uses the screen with mouse focus. |
| Sint32 CRM64Pro::CursorMgr::getPosition | ( | float * | fX, |
| float * | fY ) |
Get the mouse cursor position.
| fX | a float pointer filled in with X mouse position. If nullptr is passed, the method ignores the retrieving of this value. |
| fY | a float pointer filled in with Y mouse position. If nullptr is passed, the method ignores the retrieving of this value. |
| Sint32 CRM64Pro::CursorMgr::getButtons | ( | ) |
Get the mouse buttons.
| Sint32 CRM64Pro::CursorMgr::getButtonsPrev | ( | ) |
Get the previous mouse buttons.
| Sint32 CRM64Pro::CursorMgr::getFocus | ( | ) |
Get the Screen id which currently has mouse focus.
| Sint32 CRM64Pro::CursorMgr::child | ( | Sint32 | idCur | ) |
Create a child cursor dependant on the provided one(the parent).
A child cursor uses parent's attributes and creates a child image for different attributes. Currently only different Hotspots are supported, as colorkey cannot be modified on child images and other attributes are not supported by the SDL cursor system.
| idCur | parent Cursor id. If the provided cursor is a child, the request is redirected to its parent. |
| Sint32 CRM64Pro::CursorMgr::load | ( | const string & | sFileCDC, |
| const string & | sName ) |
Load a cursor stored in a CDC file.
| sFileCDC | string containing [directory]+filename. Directory separators '\' and '/' are supported. |
| sName | string with the cursor name (max 64 characters). If already exists, creates a child instead. |
| Sint32 CRM64Pro::CursorMgr::load | ( | const Sint32 | idCDC, |
| const string & | sName ) |
Load a cursor stored in a CDC file.
| idCDC | CDC id. |
| sName | string with the cursor name (max 64 characters). If already exists, creates a child instead. |
| Sint32 CRM64Pro::CursorMgr::remove | ( | Sint32 | idCDC, |
| const string & | sName ) |
Remove a cursor stored in a CDC file.
| idCDC | CDC id. |
| sName | string with the cursor name (maximum size of 64 characters). |