Do not copy texture file on itself
This commit is contained in:
parent
1bcdf9271e
commit
762a183b6b
|
@ -201,6 +201,9 @@ std::shared_ptr<TextureData> TextureBuilder::simple(int rawTexIndex, const std::
|
||||||
} else if (!relativeFilename.empty()) {
|
} else if (!relativeFilename.empty()) {
|
||||||
image = new ImageData(relativeFilename, relativeFilename);
|
image = new ImageData(relativeFilename, relativeFilename);
|
||||||
std::string outputPath = outputFolder + "/" + 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 (FileUtils::CopyFile(rawTexture.fileLocation, outputPath, true)) {
|
||||||
if (verboseOutput) {
|
if (verboseOutput) {
|
||||||
fmt::printf("Copied texture '%s' to output folder: %s\n", textureName, outputPath);
|
fmt::printf("Copied texture '%s' to output folder: %s\n", textureName, outputPath);
|
||||||
|
|
|
@ -34,7 +34,7 @@ bool CopyFile(
|
||||||
bool createPath = false);
|
bool createPath = false);
|
||||||
|
|
||||||
inline std::string GetAbsolutePath(const std::string& filePath) {
|
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() {
|
inline std::string GetCurrentFolder() {
|
||||||
|
|
Loading…
Reference in New Issue