From f9f4238ddabad226e394792e61e517d46d4cc39e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 6 Jan 2004 06:00:03 +0000 Subject: [PATCH] cleanup --- stepmania/src/RageFileDriverDirect.cpp | 46 ------------------ stepmania/src/RageFileDriverDirectHelpers.cpp | 47 +++++++++++++++++++ stepmania/src/RageFileDriverDirectHelpers.h | 1 + 3 files changed, 48 insertions(+), 46 deletions(-) diff --git a/stepmania/src/RageFileDriverDirect.cpp b/stepmania/src/RageFileDriverDirect.cpp index 2d27edf444..7fedc2ba30 100644 --- a/stepmania/src/RageFileDriverDirect.cpp +++ b/stepmania/src/RageFileDriverDirect.cpp @@ -152,52 +152,6 @@ RageFileDriverDirect::RageFileDriverDirect( CString root_ ): root += '/'; } -/* mkdir -p. Doesn't fail if Path already exists and is a directory. */ -static bool CreateDirectories( CString Path ) -{ - CStringArray parts; - CString curpath; - split(Path, "/", parts); - - for(unsigned i = 0; i < parts.size(); ++i) - { - curpath += parts[i] + "/"; - -#if defined(WIN32) - if( i == 0 && curpath.size() > 1 && curpath[1] == ':' ) - { - /* Don't try to create the drive letter alone. */ - continue; - } -#endif - - if( DoMkdir(curpath, 0755) == 0 ) - continue; - - if(errno == EEXIST) - continue; // we expect to see this error - - // Log the error, but continue on. - /* When creating a directory that already exists over Samba, Windows is - * returning ENOENT instead of EEXIST. */ - if( LOG ) - LOG->Warn("Couldn't create %s: %s", curpath.c_str(), strerror(errno) ); - - /* Make sure it's a directory. */ - struct stat st; - DoStat( curpath, &st ); - if( !(st.st_mode & S_IFDIR) ) - { - if( LOG ) - LOG->Warn("Couldn't create %s: path exists and is not a directory", curpath.c_str() ); - - return false; - } - } - - return true; -} - static CString MakeTempFilename( const CString &sPath ) { diff --git a/stepmania/src/RageFileDriverDirectHelpers.cpp b/stepmania/src/RageFileDriverDirectHelpers.cpp index 79cc4d6bda..a5810ca5f1 100644 --- a/stepmania/src/RageFileDriverDirectHelpers.cpp +++ b/stepmania/src/RageFileDriverDirectHelpers.cpp @@ -1,6 +1,7 @@ #include "global.h" #include "RageFileDriverDirectHelpers.h" #include "RageUtil.h" +#include "RageLog.h" #include #include @@ -109,6 +110,7 @@ int WinMoveFile( CString sOldPath, CString sNewPath ) return WinMoveFileInternal( sOldPath, sNewPath ); } +#endif bool PathReady( CString path ) { @@ -156,4 +158,49 @@ bool PathReady( CString path ) #endif } +/* mkdir -p. Doesn't fail if Path already exists and is a directory. */ +bool CreateDirectories( CString Path ) +{ + CStringArray parts; + CString curpath; + split(Path, "/", parts); + + for(unsigned i = 0; i < parts.size(); ++i) + { + curpath += parts[i] + "/"; + +#if defined(WIN32) + if( i == 0 && curpath.size() > 1 && curpath[1] == ':' ) + { + /* Don't try to create the drive letter alone. */ + continue; + } #endif + + if( DoMkdir(curpath, 0755) == 0 ) + continue; + + if(errno == EEXIST) + continue; // we expect to see this error + + // Log the error, but continue on. + /* When creating a directory that already exists over Samba, Windows is + * returning ENOENT instead of EEXIST. */ + if( LOG ) + LOG->Warn("Couldn't create %s: %s", curpath.c_str(), strerror(errno) ); + + /* Make sure it's a directory. */ + struct stat st; + DoStat( curpath, &st ); + if( !(st.st_mode & S_IFDIR) ) + { + if( LOG ) + LOG->Warn("Couldn't create %s: path exists and is not a directory", curpath.c_str() ); + + return false; + } + } + + return true; +} + diff --git a/stepmania/src/RageFileDriverDirectHelpers.h b/stepmania/src/RageFileDriverDirectHelpers.h index 6d6c2f6d4e..480ff8840b 100644 --- a/stepmania/src/RageFileDriverDirectHelpers.h +++ b/stepmania/src/RageFileDriverDirectHelpers.h @@ -27,6 +27,7 @@ int WinMoveFile( CString sOldPath, CString sNewPath ); #define O_BINARY 0 #endif +bool CreateDirectories( CString Path ); bool PathReady( CString path ); #endif