Created
February 23, 2022 22:47
-
-
Save hasherezade/2c7837874f7adf0f73192f4d861d83c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <Windows.h> | |
#pragma comment(lib,"LZ32.lib") | |
bool decompress(LPSTR infile, LPSTR outfile) | |
{ | |
INT hin, hout = 0; | |
OFSTRUCT ofin = { 0 }; | |
OFSTRUCT ofout = { 0 }; | |
LONG error = 0; | |
if ((hin = LZOpenFileA(infile, &ofin, OF_READ)) < 0) | |
{ | |
std::cerr << "can't open input file: " << infile << "\n"; | |
return false; | |
} | |
if ((hout = LZOpenFileA(outfile, &ofout, OF_CREATE | OF_WRITE)) < 0) | |
{ | |
LZClose(hin); | |
std::cerr << "can't open output file: "<< outfile << "\n"; | |
return false; | |
} | |
error = LZCopy(hin, hout); | |
LZClose(hin); | |
LZClose(hout); | |
if (error < 0) | |
{ | |
std::cerr << "LZCopy failed, error is: " << error << "\n"; | |
return false; | |
} | |
return true; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
if (argc < 3) { | |
return 0; | |
} | |
if (decompress(argv[1], argv[2])) { | |
std::cout << "Success!\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment