remove CreateDirectories and Rename
This commit is contained in:
@@ -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 )
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include "RageUtil_FileDB.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SAFE_ Macros
|
||||
@@ -175,9 +174,6 @@ void split( const wstring &Source, const wstring &Deliminator, vector<wstring> &
|
||||
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<char>
|
||||
};
|
||||
typedef basic_string<char,char_traits_char_nocase> 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
|
||||
|
||||
Reference in New Issue
Block a user