From 03ff8110986d71e79b84e7c7bea8fdc912b6b8b7 Mon Sep 17 00:00:00 2001 From: lasalvavida Date: Sun, 5 Aug 2018 14:08:07 -0400 Subject: [PATCH 1/2] Need to return to working directory after checking if path exists --- COLLADABaseUtils/src/COLLADABUUtils.cpp | 30 ++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/COLLADABaseUtils/src/COLLADABUUtils.cpp b/COLLADABaseUtils/src/COLLADABUUtils.cpp index a595fdfd7..9f5cab737 100644 --- a/COLLADABaseUtils/src/COLLADABUUtils.cpp +++ b/COLLADABaseUtils/src/COLLADABUUtils.cpp @@ -205,7 +205,7 @@ namespace COLLADABU start = text.find_first_not_of(separators, stop+1); } } - + #ifdef COLLADABU_OS_WIN //-------------------------------- bool Utils::createDirectoryIfNeeded( const WideString &pathString ) @@ -232,7 +232,7 @@ namespace COLLADABU } #endif - + //-------------------------------- bool Utils::createDirectoryIfNeeded( const String &pathString ) { @@ -298,12 +298,14 @@ namespace COLLADABU for (std::list::const_iterator iPath = paths.begin(); iPath != paths.end(); ++iPath) { // if path exists - if (_wchdir((*iPath).c_str()) == 0) + if (_wchdir((*iPath).c_str()) == 0) { + _wchdir(currentPath); continue; + } // path does not exist, try to create it _wmkdir((*iPath).c_str()); - + if (_wchdir((*iPath).c_str()) != 0) { pathExists = false; @@ -316,7 +318,7 @@ namespace COLLADABU return pathExists; } #endif - + //-------------------------------- bool Utils::createDirectoryRecursive( const String &pathString ) { @@ -349,12 +351,14 @@ namespace COLLADABU for (std::list::const_iterator iPath = paths.begin(); iPath != paths.end(); ++iPath) { // if path exists - if (_chdir((*iPath).c_str()) == 0) + if (_chdir((*iPath).c_str()) == 0) { + _chdir(currentPath); continue; + } // path does not exist, try to create it _mkdir((*iPath).c_str()); - + if (_chdir((*iPath).c_str()) != 0) { pathExists = false; @@ -378,7 +382,7 @@ namespace COLLADABU // path does not exist, try to create it mkdir((*iPath).c_str(), 0755); - + if (chdir((*iPath).c_str()) != 0) { pathExists = false; @@ -391,7 +395,7 @@ namespace COLLADABU #endif return pathExists; } - + #ifdef COLLADABU_OS_WIN //-------------------------------- bool Utils::directoryExists( const WideString &pathString ) @@ -412,7 +416,7 @@ namespace COLLADABU } #endif - + //-------------------------------- bool Utils::directoryExists( const String &pathString ) { @@ -437,7 +441,7 @@ namespace COLLADABU struct stat st; if(stat(pathString.c_str(),&st) == 0) pathExists = true; - + #endif return pathExists; @@ -471,8 +475,8 @@ namespace COLLADABU size_t length = strlen(command); if( length > 4096) return false; - - + + int status = system(command); copystatus = (status == 0 ? true : false); #endif From 9c982903d791040b6a10761c1340249878f6f89a Mon Sep 17 00:00:00 2001 From: Rob Taglang Date: Thu, 18 Oct 2018 11:34:40 -0400 Subject: [PATCH 2/2] Change spaces to tabs --- COLLADABaseUtils/src/COLLADABUUtils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/COLLADABaseUtils/src/COLLADABUUtils.cpp b/COLLADABaseUtils/src/COLLADABUUtils.cpp index 9f5cab737..982bf618b 100644 --- a/COLLADABaseUtils/src/COLLADABUUtils.cpp +++ b/COLLADABaseUtils/src/COLLADABUUtils.cpp @@ -299,9 +299,9 @@ namespace COLLADABU { // if path exists if (_wchdir((*iPath).c_str()) == 0) { - _wchdir(currentPath); + _wchdir(currentPath); continue; - } + } // path does not exist, try to create it _wmkdir((*iPath).c_str()); @@ -352,9 +352,9 @@ namespace COLLADABU { // if path exists if (_chdir((*iPath).c_str()) == 0) { - _chdir(currentPath); + _chdir(currentPath); continue; - } + } // path does not exist, try to create it _mkdir((*iPath).c_str());