From 74a1435eedd89d6a722dc3d2dfa3786e77a535c4 Mon Sep 17 00:00:00 2001 From: ptc-tgamper <48118652+ptc-tgamper@users.noreply.github.com> Date: Fri, 12 Jan 2024 17:38:20 +0100 Subject: [PATCH] Fix #1031 (#1032) file_writer_utils.cc - fix preprocessor check and wrong path check --- src/draco/io/file_writer_utils.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/draco/io/file_writer_utils.cc b/src/draco/io/file_writer_utils.cc index 3dab80b..08ca4c2 100644 --- a/src/draco/io/file_writer_utils.cc +++ b/src/draco/io/file_writer_utils.cc @@ -38,11 +38,10 @@ bool DirectoryExists(const std::string &path_arg) { struct stat path_stat; std::string path = path_arg; -#if defined(_WIN32) && not defined(__MINGW32__) +#if defined(_WIN32) && !defined(__MINGW32__) // Avoid a silly windows issue: stat() will fail on a drive letter missing the - // trailing slash. - if (path.size() > 0 && path[path.size()] != '\\' && - path[path.size()] != '/') { + // trailing slash. To keep it simple, append a path separator to all paths. + if (!path.empty() && path.back() != '\\' && path.back() != '/') { path.append("\\"); } #endif @@ -68,9 +67,7 @@ bool CheckAndCreatePathForFile(const std::string &filename) { const ghc::filesystem::path ghc_path(path); ghc::filesystem::create_directories(ghc_path); #endif // DRACO_TRANSCODER_SUPPORTED - const bool directory_exists = DirectoryExists(path); - - return directory_exists; + return DirectoryExists(path); } } // namespace draco