#include <lzexpand.h> |
LONG LZCopy(hfSource, hfDest) | |||||
HFILE hfSource; | /* handle of source file | */ | |||
HFILE hfDest; | /* handle of destination file | */ |
The LZCopy function copies a source file to a destination file. If the source file was compressed by Microsoft File Compression Utility (COMPRESS.EXE), this function creates a decompressed destination file. If the source file was not compressed, this function duplicates the original file.
hfSource
Identifies the source file. (This handle is returned by the LZOpenFile function when a compressed file is opened.)
hfDest
Identifies the destination file.
The return value is the size, in bytes, of the destination file if the function is successful. Otherwise, it is an error value that is less than zero and may be one of the following:
Value | Meaning |
LZERROR_BADINHANDLE | The handle identifying the source file was not valid. |
LZERROR_BADOUTHANDLE | The handle identifying the destination file was not valid. |
LZERROR_GLOBALLOC | There is insufficient memory for the required buffers. |
LZERROR_GLOBLOCK | The handle identifying the internal data structures is invalid. |
LZERROR_READ | The source file format was not valid. |
LZERROR_UNKNOWNALG | The source file was compressed with an unrecognized compression algorithm. |
LZERROR_WRITE | There is insufficient space for the output file. |
This function is designed for single-file copy operations. (Use the CopyLZFile function for multiple-file copy operations.)
If the function is successful, the file identified by hfDest is uncompressed.
If the source or destination file is opened by a C run-time function (rather than the _lopen or OpenFile function), it must be opened in binary mode.
The following example uses the LZCopy function to copy a file:
char szSrc[] = {"readme.txt"};
char szDst[] = {"readme.bak"};
OFSTRUCT ofStrSrc;
OFSTRUCT ofStrDest;
HFILE hfSrcFile, hfDstFile;
/* Open the source file. */
hfSrcFile = LZOpenFile(szSrc, &ofStrSrc, OF_READ);
/* Create the destination file. */
hfDstFile = LZOpenFile(szDst, &ofStrDest, OF_CREATE);
/* Copy the source file to the destination file. */
LZCopy(hfSrcFile, hfDstFile);
/* Close the files. */
LZClose(hfSrcFile);
LZClose(hfDstFile);