From c6b550e2efbfc56de8e64cd72a046e225e973492 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 7 Dec 2003 04:20:07 +0000 Subject: [PATCH] remove CreateDirectories and Rename --- stepmania/src/RageUtil.cpp | 50 +------------------------------------- stepmania/src/RageUtil.h | 16 +++++++++--- 2 files changed, 13 insertions(+), 53 deletions(-) diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 442f5c6dee..6403b7280b 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -301,7 +301,7 @@ CString GetExtension( CString sPath ) CString GetCwd() { #ifdef _XBOX - return "D:\\" ; + return SYS_BASE_PATH; #else char buf[PATH_MAX]; bool ret = getcwd(buf, PATH_MAX) != NULL; @@ -310,54 +310,6 @@ CString GetCwd() #endif } -/* mkdir -p. Doesn't fail if Path already exists and is a directory. */ -bool CreateDirectories( CString Path ) -{ - CStringArray parts; - CString curpath; - split(Path, SLASH, parts); - - for(unsigned i = 0; i < parts.size(); ++i) - { - curpath += parts[i] + SLASH; - if( mkdir(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. */ - /* On Win32 when Path is only a drive letter (e.g. "i:\"), the result is - * EINVAL. */ - if( LOG ) - LOG->Warn("Couldn't create %s: %s", curpath.c_str(), strerror(errno) ); - - /* Make sure it's a directory. */ - FlushDirCache(); - if( !IsADirectory(curpath) ) - { - if( LOG ) - LOG->Warn("Couldn't create %s: path exists and is not a directory", curpath.c_str() ); - - // HACK: IsADirectory doesn't work if Path contains a drive letter. - // So, ignore IsADirectory's result and continue trying to create - // directories anyway. This shouldn't change behavior, but - // is inefficient because we don't bail early on an error. - //return false; - } - } - - return true; -} - -bool Rename( const char *oldname, const char *newname ) -{ - return 0 == rename( oldname, newname ); -} - - /* Reference: http://www.theorem.com/java/CRC32.java, rewritten by Glenn Maynard. * Public domain. */ unsigned int GetHashForString ( CString s ) diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index f9873077e5..e43264fdd0 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -13,7 +13,6 @@ */ #include -#include "RageUtil_FileDB.h" //----------------------------------------------------------------------------- // SAFE_ Macros @@ -175,9 +174,6 @@ void split( const wstring &Source, const wstring &Deliminator, vector & CString join(const CString &Deliminator, const CStringArray& Source); CString GetCwd(); -bool CreateDirectories( CString Path ); -bool Rename( const char *oldname, const char *newname ); -void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs=false, bool bReturnPathToo=false ); unsigned int GetHashForString( CString s ); unsigned int GetHashForFile( CString sPath ); @@ -280,4 +276,16 @@ struct char_traits_char_nocase: public char_traits }; typedef basic_string istring; +/* Compatibility/convenience shortcuts. These are actually defined in RageFileManager.h, but + * declared here since they're used in many places. */ +void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs=false, bool bReturnPathToo=false ); +bool DoesFileExist( const CString &sPath ); +bool IsAFile( const CString &sPath ); +bool IsADirectory( const CString &sPath ); +bool ResolvePath(CString &path); +unsigned GetFileSizeInBytes( const CString &sFilePath ); +int GetFileModTime( const CString &sPath ); +void FlushDirCache(); + + #endif