@@ -205,7 +205,7 @@ namespace COLLADABU
205205 start = text.find_first_not_of (separators, stop+1 );
206206 }
207207 }
208-
208+
209209#ifdef COLLADABU_OS_WIN
210210 // --------------------------------
211211 bool Utils::createDirectoryIfNeeded ( const WideString &pathString )
@@ -232,7 +232,7 @@ namespace COLLADABU
232232
233233 }
234234#endif
235-
235+
236236 // --------------------------------
237237 bool Utils::createDirectoryIfNeeded ( const String &pathString )
238238 {
@@ -298,12 +298,14 @@ namespace COLLADABU
298298 for (std::list<WideString>::const_iterator iPath = paths.begin (); iPath != paths.end (); ++iPath)
299299 {
300300 // if path exists
301- if (_wchdir ((*iPath).c_str ()) == 0 )
301+ if (_wchdir ((*iPath).c_str ()) == 0 ) {
302+ _wchdir (currentPath);
302303 continue ;
304+ }
303305
304306 // path does not exist, try to create it
305307 _wmkdir ((*iPath).c_str ());
306-
308+
307309 if (_wchdir ((*iPath).c_str ()) != 0 )
308310 {
309311 pathExists = false ;
@@ -316,7 +318,7 @@ namespace COLLADABU
316318 return pathExists;
317319 }
318320#endif
319-
321+
320322 // --------------------------------
321323 bool Utils::createDirectoryRecursive ( const String &pathString )
322324 {
@@ -349,12 +351,14 @@ namespace COLLADABU
349351 for (std::list<String>::const_iterator iPath = paths.begin (); iPath != paths.end (); ++iPath)
350352 {
351353 // if path exists
352- if (_chdir ((*iPath).c_str ()) == 0 )
354+ if (_chdir ((*iPath).c_str ()) == 0 ) {
355+ _chdir (currentPath);
353356 continue ;
357+ }
354358
355359 // path does not exist, try to create it
356360 _mkdir ((*iPath).c_str ());
357-
361+
358362 if (_chdir ((*iPath).c_str ()) != 0 )
359363 {
360364 pathExists = false ;
@@ -378,7 +382,7 @@ namespace COLLADABU
378382
379383 // path does not exist, try to create it
380384 mkdir ((*iPath).c_str (), 0755 );
381-
385+
382386 if (chdir ((*iPath).c_str ()) != 0 )
383387 {
384388 pathExists = false ;
@@ -391,7 +395,7 @@ namespace COLLADABU
391395#endif
392396 return pathExists;
393397 }
394-
398+
395399#ifdef COLLADABU_OS_WIN
396400 // --------------------------------
397401 bool Utils::directoryExists ( const WideString &pathString )
@@ -412,7 +416,7 @@ namespace COLLADABU
412416
413417 }
414418#endif
415-
419+
416420 // --------------------------------
417421 bool Utils::directoryExists ( const String &pathString )
418422 {
@@ -437,7 +441,7 @@ namespace COLLADABU
437441 struct stat st;
438442 if (stat (pathString.c_str (),&st) == 0 )
439443 pathExists = true ;
440-
444+
441445#endif
442446
443447 return pathExists;
@@ -471,8 +475,8 @@ namespace COLLADABU
471475 size_t length = strlen (command);
472476 if ( length > 4096 )
473477 return false ;
474-
475-
478+
479+
476480 int status = system (command);
477481 copystatus = (status == 0 ? true : false );
478482#endif
0 commit comments