int compress(char *inFileName,char *outFileName)
{
char rs[800] = { 0 };
CFileSeqInStream inStream;
CFileOutStream outStream;
int res;
FileSeqInStream_CreateVTable(&inStream);
File_Construct(&inStream.file);
FileOutStream_CreateVTable(&outStream);
File_Construct(&outStream.file);
{
size_t t4 = sizeof(UInt32);
size_t t8 = sizeof(UInt64);
if (t4 != 4 || t8 != 8)
return PrintError(rs, "Incorrect UInt32 or UInt64");
}
if (InFile_Open(&inStream.file, inFileName) != 0)
return PrintError(rs, "Can not open input file");
if (OutFile_Open(&outStream.file, outFileName ) != 0)
return PrintError(rs, "Can not open output file");
UInt64 fileSize;
File_GetLength(&inStream.file, &fileSize);
res = Encode(&outStream.s, &inStream.s, fileSize, rs);
File_Close(&outStream.file);
File_Close(&inStream.file);
if (res != SZ_OK)
{
if (res == SZ_ERROR_MEM)
return PrintError(rs, kCantAllocateMessage);
else if (res == SZ_ERROR_DATA)
return PrintError(rs, kDataErrorMessage);
else if (res == SZ_ERROR_WRITE)
return PrintError(rs, kCantWriteMessage);
else if (res == SZ_ERROR_READ)
return PrintError(rs, kCantReadMessage);
return PrintErrorNumber(rs, res);
}
return 0;
}
int Decompress(char *inFileName,char *outFileName)
{
char rs[800] = { 0 };
CFileSeqInStream inStream;
CFileOutStream outStream;
int res;
//Bool useOutFile = False;
FileSeqInStream_CreateVTable(&inStream);
File_Construct(&inStream.file);
FileOutStream_CreateVTable(&outStream);
File_Construct(&outStream.file);
size_t t4 = sizeof(UInt32);
size_t t8 = sizeof(UInt64);
if (t4 != 4 || t8 != 8)
return PrintError(rs, "Incorrect UInt32 or UInt64");
if (InFile_Open(&inStream.file, inFileName) != 0)
return PrintError(rs, "Can not open input file");
if (OutFile_Open(&outStream.file, outFileName) != 0)
return PrintError(rs, "Can not open output file");
res = Decode(&outStream.s, &inStream.s);
File_Close(&outStream.file);
File_Close(&inStream.file);
if (res != SZ_OK)
{
if (res == SZ_ERROR_MEM)
return PrintError(rs, kCantAllocateMessage);
else if (res == SZ_ERROR_DATA)
return PrintError(rs, kDataErrorMessage);
else if (res == SZ_ERROR_WRITE)
return PrintError(rs, kCantWriteMessage);
else if (res == SZ_ERROR_READ)
return PrintError(rs, kCantReadMessage);
return PrintErrorNumber(rs, res);
}
return 0;
}
int compress(char *inFileName,char *outFileName)
{
char rs[800] = { 0 };
CFileSeqInStream inStream;
CFileOutStream outStream;
int res;
FileSeqInStream_CreateVTable(&inStream);
File_Construct(&inStream.file);
FileOutStream_CreateVTable(&outStream);
File_Construct(&outStream.file);
{
size_t t4 = sizeof(UInt32);
size_t t8 = sizeof(UInt64);
if (t4 != 4 || t8 != 8)
return PrintError(rs, "Incorrect UInt32 or UInt64");
}
if (InFile_Open(&inStream.file, inFileName) != 0)
return PrintError(rs, "Can not open input file");
if (OutFile_Open(&outStream.file, outFileName ) != 0)
return PrintError(rs, "Can not open output file");
UInt64 fileSize;
File_GetLength(&inStream.file, &fileSize);
res = Encode(&outStream.s, &inStream.s, fileSize, rs);
File_Close(&outStream.file);
File_Close(&inStream.file);
if (res != SZ_OK)
{
if (res == SZ_ERROR_MEM)
return PrintError(rs, kCantAllocateMessage);
else if (res == SZ_ERROR_DATA)
return PrintError(rs, kDataErrorMessage);
else if (res == SZ_ERROR_WRITE)
return PrintError(rs, kCantWriteMessage);
else if (res == SZ_ERROR_READ)
return PrintError(rs, kCantReadMessage);
return PrintErrorNumber(rs, res);
}
return 0;
}
int Decompress(char *inFileName,char *outFileName)
{
char rs[800] = { 0 };
CFileSeqInStream inStream;
CFileOutStream outStream;
int res;
//Bool useOutFile = False;
FileSeqInStream_CreateVTable(&inStream);
File_Construct(&inStream.file);
FileOutStream_CreateVTable(&outStream);
File_Construct(&outStream.file);
size_t t4 = sizeof(UInt32);
size_t t8 = sizeof(UInt64);
if (t4 != 4 || t8 != 8)
return PrintError(rs, "Incorrect UInt32 or UInt64");
if (InFile_Open(&inStream.file, inFileName) != 0)
return PrintError(rs, "Can not open input file");
if (OutFile_Open(&outStream.file, outFileName) != 0)
return PrintError(rs, "Can not open output file");
res = Decode(&outStream.s, &inStream.s);
File_Close(&outStream.file);
File_Close(&inStream.file);
if (res != SZ_OK)
{
if (res == SZ_ERROR_MEM)
return PrintError(rs, kCantAllocateMessage);
else if (res == SZ_ERROR_DATA)
return PrintError(rs, kDataErrorMessage);
else if (res == SZ_ERROR_WRITE)
return PrintError(rs, kCantWriteMessage);
else if (res == SZ_ERROR_READ)
return PrintError(rs, kCantReadMessage);
return PrintErrorNumber(rs, res);
}
return 0;
}
To copy to clipboard, switch view to plain text mode
#Now just call the main current project
#include "lzma920/C/Util/Lzma/LzmaUtil.c"
int main(int argc, char *argv[])
{
//MainWindow w;
//w.show();
char *inFileName="c:/dbforcacad001.db";
char *outFileName="c:/dbforcacad001.lzma";
compress(inFileName,outFileName);
inFileName=outFileName;
outFileName="c:/dbforcacad001.lzma.db";
Decompress(inFileName,outFileName);
//return a.exec();
}
#include "lzma920/C/Util/Lzma/LzmaUtil.c"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//MainWindow w;
//w.show();
char *inFileName="c:/dbforcacad001.db";
char *outFileName="c:/dbforcacad001.lzma";
compress(inFileName,outFileName);
inFileName=outFileName;
outFileName="c:/dbforcacad001.lzma.db";
Decompress(inFileName,outFileName);
//return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks