6 #include <MpqArchive.h>
7 #include <fmt/format.h>
10 using namespace WorldStone;
11 int main(
int argc,
char* argv[])
14 const char* mpqFilename = argv[1];
15 const char* fileToExtract = argv[2];
17 if (!mpqArchive.good()) fmt::print(
"Could not open {}\n", mpqFilename);
18 if (!mpqArchive.exists(fileToExtract))
19 fmt::print(
"The file {} was not found in {}\n", fileToExtract, mpqFilename);
22 fmt::print(
"The file is in the MPQ !\n");
23 StreamPtr file = mpqArchive.open(fileToExtract);
24 std::ofstream outFile(argv[3], std::ofstream::binary);
25 if (!outFile) fmt::print(
"Couldn't create output file\n");
26 while (file && file->good() && outFile)
29 size_t readFromMpq = file->read(buffer,
sizeof(buffer));
30 outFile.write(buffer, static_cast<std::streamsize>(readFromMpq));
35 fmt::print(
"MPQextract usage : MPQextract archive.mpq filetoextract outputfile\n");
A wrapper to manage MPQ archives.