CRM32Pro SDK  v5.22
List of all members | Public Member Functions

IStuffDPF. More...

Detailed Description

IStuffDPF.

Interface to manage DPF.

Public Member Functions

int AddData (int idDPF, DPF_BlockData *info)
 Add a data block to the given DPF. More...
 
int AddFile (int idDPF, char *filename)
 Add a file to a DPF. More...
 
void Close (int idDPF)
 Close a DPF. More...
 
int Compact (char *filename)
 Compact a DPF removing all deleted blocks. It can also fix a block corruption. More...
 
int Create (char *filename)
 Create a new DPF v4.0. More...
 
int Delete (int idDPF, DPF_BlockData *info)
 Delete a specific block. More...
 
int FindFirst (int idDPF, DPF_BlockData *info)
 Find first block on the given DPF. More...
 
int FindNext (int idDPF, DPF_BlockData *info)
 Find next block. More...
 
void Flush (int idDPF)
 Flush the given idDPF. More...
 
int FreeBlock (DPF_BlockData *)
 Free a loaded block.
 
char * GetFilename (int idDPF)
 Get the filename given a valid idDPF. More...
 
char GetFragment (int idDPF)
 Return fragmentation percent of given DPF. More...
 
int GetNumBlocks (int idDPF)
 Return total blocks number(including working and deleted ones) of given DPF. More...
 
int GetNumDelBlocks (int idDPF)
 Return only deleted blocks number of given DPF. More...
 
int GetSize (int idDPF)
 Return total file size. More...
 
int LoadBlock (int idDPF, char *type, char *name, DPF_BlockData *info)
 Load the block that matches the given type and name. More...
 
int Open (char *filename)
 Load a DPF v4.0. If you open a v3.0, it will update it automatically to v4.0. More...
 
int Protect (char *filename, unsigned char *key, unsigned char keylen)
 Protect your DPF with heavy encription creating a new DPF.
 
int Search (int idDPF, DPF_BlockData *info)
 Search for a specific block. More...
 
void SetAccessMode (char mode)
 Set access mode to blocks on DPF.
 
void SetPassword (unsigned char *key, unsigned char keylen)
 Set the password to access to your protected DPF.
 
int UnProtect (char *filename, unsigned char *key, unsigned char keylen)
 Unprotect your previously protected DPF.
 

Member Function Documentation

int CRM32Pro_IStuffDPF::AddData ( int  idDPF,
DPF_BlockData info 
)

Add a data block to the given DPF.

Parameters
idDPFDPF's ID to add data
infofilled data block
Returns
-1 Data block already exists.
0 Failed.
any other positive value, Ok and packed size of the added block
int CRM32Pro_IStuffDPF::AddFile ( int  idDPF,
char *  filename 
)

Add a file to a DPF.

Parameters
idDPFDPF's ID to add file
filenamefile to be added
Returns
-1 File block already exists.
0 Failed.
any other positive value, Ok and packed size of the added block
void CRM32Pro_IStuffDPF::Close ( int  idDPF)

Close a DPF.

Parameters
idDPFDPF's ID to close
int CRM32Pro_IStuffDPF::Compact ( char *  filename)

Compact a DPF removing all deleted blocks. It can also fix a block corruption.

Note that it performs a physical delete. The given DPF must be closed before to call this method.

Parameters
filenameDPF file name to perform the compact process.
Returns
0 Failed
1 Ok
int CRM32Pro_IStuffDPF::Create ( char *  filename)

Create a new DPF v4.0.

Parameters
filenamename and optional path of the new DPF
Returns
-1 Failed
any other value, the DPF's ID
int CRM32Pro_IStuffDPF::Delete ( int  idDPF,
DPF_BlockData info 
)

Delete a specific block.

Note this is a logical delete

Parameters
idDPFDPF's ID to delete given block
infofilled data block to search and delete(only name and type are needed)
Returns
0 Failed
1 Ok
int CRM32Pro_IStuffDPF::FindFirst ( int  idDPF,
DPF_BlockData info 
)

Find first block on the given DPF.

Parameters
idDPFDPF's ID to find first block
infofilled data block(only info, not data)
Returns
0 There was not block found
1 There was block found
2 2 Error
int CRM32Pro_IStuffDPF::FindNext ( int  idDPF,
DPF_BlockData info 
)

Find next block.

Parameters
idDPFDPF's ID to find next block
infofilled data block(only info, not data)
Returns
0 There was not block found
1 There was block found
2 Error
void CRM32Pro_IStuffDPF::Flush ( int  idDPF)

Flush the given idDPF.

IStuffDPF uses buffering algorithms to speedup all IO operations. Once you save a data block, it may not be immediately saved to disk. If you want to assure this, you have to flush the given idDPF.

Parameters
idDPFDPF's ID to flush
char * CRM32Pro_IStuffDPF::GetFilename ( int  idDPF)

Get the filename given a valid idDPF.

Parameters
idDPFDPF's ID to get its filename
Returns
Pointer to a char with the filename
char CRM32Pro_IStuffDPF::GetFragment ( int  idDPF)

Return fragmentation percent of given DPF.

Parameters
idDPFDPF's ID to get fragment percent
Returns
0-100 in %. 100% is excellent and with less than 70%, a compaction is needed(using Compact())
int CRM32Pro_IStuffDPF::GetNumBlocks ( int  idDPF)

Return total blocks number(including working and deleted ones) of given DPF.

Parameters
idDPFDPF's ID to count blocks
Returns
number of all blocks of the given DPF
int CRM32Pro_IStuffDPF::GetNumDelBlocks ( int  idDPF)

Return only deleted blocks number of given DPF.

Parameters
idDPFDPF's ID to count deleted blocks
Returns
0 Failed
any other value, the number of deleted blocks
int CRM32Pro_IStuffDPF::GetSize ( int  idDPF)

Return total file size.

Parameters
idDPFDPF's ID to get size
Returns
size in kilobytes of given DPF
int CRM32Pro_IStuffDPF::LoadBlock ( int  idDPF,
char *  type,
char *  name,
DPF_BlockData info 
)

Load the block that matches the given type and name.

Note that once you have finish to work with returned data of info struct, you must free it using FreeBlock().

Parameters
idDPFDPF's ID to load block
typeblock type(examples of defined:"FILE","TILE"..)
namename of block. It is case sensitive.
infowhen return Ok, it has the required data
Returns
0 Failed
any other value, Ok and the real size(not the packed one) of loaded block
int CRM32Pro_IStuffDPF::Open ( char *  filename)

Load a DPF v4.0. If you open a v3.0, it will update it automatically to v4.0.

Parameters
filenamename of file
Returns
-1 Failed
any other value, the DPF's ID(idDPF)
int CRM32Pro_IStuffDPF::Search ( int  idDPF,
DPF_BlockData info 
)

Search for a specific block.

Parameters
idDPFDPF's ID to find the given block
infopointer to DPF_BlockData struct with the name and type to look for.
If it is found, it returns more information and data = NULL
Returns
0 The given block was not found
1 The given block was found
2 Error

The documentation for this class was generated from the following files: