#include <lzexpand.h> |
int LZStart(void) |
The LZStart function allocates the buffers that the CopyLZFile function uses to copy a source file to a destination file.
This function has no parameters.
The return value is nonzero if the function is successful. Otherwise, it is LZERROR_GLOBALLOC.
Applications that copy (or copy and decompress) multiple consecutive files should call the LZStart, CopyLZFile, and LZDone functions. Applications that copy a single file should call the LZCopy function.
The following example uses LZStart to allocate buffers used by CopyLZFile:
#define NUM_FILES 4
char *szSrc[NUM_FILES] =
{"readme.txt", "data.txt", "update.txt", "list.txt"};
char *szDest[NUM_FILES] =
{"readme.bak", "data.bak", "update.bak", "list.bak"};
OFSTRUCT ofStrSrc;
OFSTRUCT ofStrDest;
HFILE hfSrcFile, hfDstFile;
int i;
/* Allocate internal buffers for the CopyLZFile function. */
LZStart();
/* Open, copy, and then close the files. */
for (i = 0; i < NUM_FILES; i++) {
hfSrcFile = LZOpenFile(szSrc[i], &ofStrSrc, OF_READ);
hfDstFile = LZOpenFile(szDest[i], &ofStrDest, OF_CREATE);
CopyLZFile(hfSrcFile, hfDstFile);
LZClose(hfSrcFile);
LZClose(hfDstFile);
}
LZDone(); /* free the internal buffers */