431a9c00a5
On Linux and macOS, using Clang to compile OpenStarbound produces about 400 MB worth of warnings during the build, making the compiler output unreadable and slowing the build down considerably. 99% of the warnings were unqualified uses of std::move and std::forward, which are now all properly qualified. Fixed a few other minor warnings about non-virtual destructors and some uses of std::move preventing copy elision on temporary objects. Most remaining warnings are now unused parameters.
54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#include "StarPackedAssetSource.hpp"
|
|
#include "StarTime.hpp"
|
|
#include "StarJsonExtra.hpp"
|
|
#include "StarFile.hpp"
|
|
|
|
using namespace Star;
|
|
|
|
int main(int argc, char** argv) {
|
|
try {
|
|
double startTime = Time::monotonicTime();
|
|
|
|
if (argc != 3) {
|
|
cerrf("Usage: {} <assets pak path> <target output directory>\n", argv[0]);
|
|
cerrf("If the target output directory does not exist it will be created\n");
|
|
return 1;
|
|
}
|
|
|
|
String inputFile = argv[1];
|
|
String outputFolderPath = argv[2];
|
|
|
|
PackedAssetSource assetsPack(inputFile);
|
|
|
|
if (!File::isDirectory(outputFolderPath))
|
|
File::makeDirectory(outputFolderPath);
|
|
|
|
File::changeDirectory(outputFolderPath);
|
|
|
|
auto allFiles = assetsPack.assetPaths();
|
|
|
|
for (auto file : allFiles) {
|
|
try {
|
|
auto fileData = assetsPack.read(file);
|
|
auto relativePath = "." + file;
|
|
auto relativeDir = File::dirName(relativePath);
|
|
File::makeDirectoryRecursive(relativeDir);
|
|
File::writeFile(fileData, relativePath);
|
|
} catch (AssetSourceException const& e) {
|
|
cerrf("Could not open file: {}\n", file);
|
|
cerrf("Reason: {}\n", outputException(e, false));
|
|
}
|
|
}
|
|
|
|
auto metadata = assetsPack.metadata();
|
|
if (!metadata.empty())
|
|
File::writeFile(Json(std::move(metadata)).printJson(2), "_metadata");
|
|
|
|
coutf("Unpacked assets to {} in {}s\n", outputFolderPath, Time::monotonicTime() - startTime);
|
|
return 0;
|
|
} catch (std::exception const& e) {
|
|
cerrf("Exception caught: {}\n", outputException(e, true));
|
|
return 1;
|
|
}
|
|
}
|