diff --git a/src/gltf/TextureBuilder.cpp b/src/gltf/TextureBuilder.cpp index ea9869a..454173c 100644 --- a/src/gltf/TextureBuilder.cpp +++ b/src/gltf/TextureBuilder.cpp @@ -180,7 +180,6 @@ std::shared_ptr TextureBuilder::simple(int rawTexIndex, const std:: const RawTexture& rawTexture = raw.GetTexture(rawTexIndex); const std::string textureName = FileUtils::GetFileBase(rawTexture.name); const std::string relativeFilename = FileUtils::GetFileName(rawTexture.fileLocation); - ImageData* image = nullptr; if (options.outputBinary) { auto bufferView = gltf.AddBufferViewForFile(*gltf.defaultBuffer, rawTexture.fileLocation); diff --git a/src/gltf/TextureBuilder.hpp b/src/gltf/TextureBuilder.hpp index 8d1bb44..e197af0 100644 --- a/src/gltf/TextureBuilder.hpp +++ b/src/gltf/TextureBuilder.hpp @@ -26,7 +26,13 @@ class TextureBuilder { const GltfOptions& options, const std::string& outputFolder, GltfModel& gltf) - : raw(raw), options(options), outputFolder(outputFolder), gltf(gltf) {} + : raw(raw), options(options), outputFolder(outputFolder), gltf(gltf) { + if (!outputFolder.empty()) { + if (outputFolder[outputFolder.size() - 1] == '/') { + this->outputFolder = outputFolder.substr(0, outputFolder.size() - 1) ; + } + } + } ~TextureBuilder() {} std::shared_ptr combine( @@ -70,7 +76,7 @@ class TextureBuilder { private: const RawModel& raw; const GltfOptions& options; - const std::string outputFolder; + std::string outputFolder; GltfModel& gltf; std::map> textureByIndicesKey; diff --git a/src/utils/File_Utils.hpp b/src/utils/File_Utils.hpp index ac1442e..8a2aa12 100644 --- a/src/utils/File_Utils.hpp +++ b/src/utils/File_Utils.hpp @@ -50,8 +50,8 @@ inline bool FolderExists(const std::string& folderPath) { } inline std::string getFolder(const std::string& path) { - auto parent = boost::filesystem::path(path).parent_path().string(); - return parent == "" ? "." : parent; + auto parent = boost::filesystem::path(path).parent_path().string(); + return parent == "" ? "." : parent; } inline std::string GetFileName(const std::string& path) { @@ -70,4 +70,8 @@ inline boost::optional GetFileSuffix(const std::string& path) { return extension.string().substr(1); } +inline bool MakeDir(const std::string& path) { + return boost::filesystem::create_directories(boost::filesystem::path(path)); +} + } // namespace FileUtils