Do not copy texture file on itself

This commit is contained in:
Jason Schutz 2021-08-30 15:23:41 -04:00 committed by K. S. Ernest (iFire) Lee
parent 1bcdf9271e
commit 762a183b6b
2 changed files with 4 additions and 1 deletions

View File

@ -201,6 +201,9 @@ std::shared_ptr<TextureData> TextureBuilder::simple(int rawTexIndex, const std::
} else if (!relativeFilename.empty()) {
image = new ImageData(relativeFilename, relativeFilename);
std::string outputPath = outputFolder + "/" + relativeFilename;
auto srcAbs = FileUtils::GetAbsolutePath(rawTexture.fileLocation);
auto dstAbs = FileUtils::GetAbsolutePath(outputPath);
if (srcAbs != dstAbs)
if (FileUtils::CopyFile(rawTexture.fileLocation, outputPath, true)) {
if (verboseOutput) {
fmt::printf("Copied texture '%s' to output folder: %s\n", textureName, outputPath);

View File

@ -34,7 +34,7 @@ bool CopyFile(
bool createPath = false);
inline std::string GetAbsolutePath(const std::string& filePath) {
return boost::filesystem::absolute(filePath).string();
return boost::filesystem::canonical(boost::filesystem::absolute(filePath)).string();
}
inline std::string GetCurrentFolder() {