From 4cf9334b9fc5a895f1d85df08b32c580b9d3ff6e Mon Sep 17 00:00:00 2001 From: Renaud Lepage Date: Fri, 26 Aug 2005 19:02:10 +0000 Subject: [PATCH] Xbox : Correct the path correction routine. We are now back. --- stepmania/src/RageFileDriverDirect.cpp | 2 +- stepmania/src/RageFileDriverDirectHelpers.cpp | 43 ++++++++----------- stepmania/src/RageFileDriverDirectHelpers.h | 1 + 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/stepmania/src/RageFileDriverDirect.cpp b/stepmania/src/RageFileDriverDirect.cpp index 95626e4e18..19e40a1361 100644 --- a/stepmania/src/RageFileDriverDirect.cpp +++ b/stepmania/src/RageFileDriverDirect.cpp @@ -271,7 +271,7 @@ RageFileObjDirect::~RageFileObjDirect() CString sNewPath = m_sPath; #if defined(WIN32) - if( WinMoveFile(sOldPath, sNewPath) ) + if( WinMoveFile(DoPathReplace(sOldPath), DoPathReplace(sNewPath)) ) return; /* We failed. */ diff --git a/stepmania/src/RageFileDriverDirectHelpers.cpp b/stepmania/src/RageFileDriverDirectHelpers.cpp index 5418a37b31..fc4924d1c6 100644 --- a/stepmania/src/RageFileDriverDirectHelpers.cpp +++ b/stepmania/src/RageFileDriverDirectHelpers.cpp @@ -21,47 +21,45 @@ /* Wrappers for low-level file functions, to work around Xbox issues: */ int DoMkdir( const CString &sPath, int perm ) { - CString TempPath = sPath; - TempPath.Replace( "/", "\\" ); - return mkdir( TempPath ); + return mkdir( DoPathReplace(sPath), perm ); } int DoOpen( const CString &sPath, int flags, int perm ) { - CString TempPath = sPath; - TempPath.Replace( "/", "\\" ); - return open( TempPath, flags, perm ); + return open( DoPathReplace(sPath), flags, perm ); } int DoStat( const CString &sPath, struct stat *st ) { - CString TempPath = sPath; - TempPath.Replace( "/", "\\" ); - return stat( sPath, st ); + return stat( DoPathReplace(sPath), st ); } int DoRemove( const CString &sPath ) { - CString TempPath = sPath; - TempPath.Replace( "/", "\\" ); - return remove( sPath ); + return remove( DoPathReplace(sPath) ); } int DoRmdir( const CString &sPath ) { - CString TempPath = sPath; - TempPath.Replace( "/", "\\" ); - return rmdir( sPath ); + return rmdir( DoPathReplace(sPath) ); } HANDLE DoFindFirstFile( const CString &sPath, WIN32_FIND_DATA *fd ) { - CString TempPath = sPath; - TempPath.Replace( "/", "\\" ); - return FindFirstFile( TempPath, fd ); + return FindFirstFile( DoPathReplace(sPath), fd ); } #endif +CString DoPathReplace(const CString &sPath) +{ + CString TempPath = sPath; +#if defined(XBOX) + TempPath.Replace( "//", "\\" ); + TempPath.Replace( "/", "\\" ); +#endif + return TempPath; +} + #if defined(WIN32) static bool WinMoveFileInternal( const CString &sOldPath, const CString &sNewPath ) @@ -100,11 +98,6 @@ static bool WinMoveFileInternal( const CString &sOldPath, const CString &sNewPat bool WinMoveFile( CString sOldPath, CString sNewPath ) { -#if defined(_XBOX) - sOldPath.Replace( "/", "\\" ); - sNewPath.Replace( "/", "\\" ); -#endif - if( WinMoveFileInternal(sOldPath, sNewPath) ) return true; if( GetLastError() != ERROR_ACCESS_DENIED ) @@ -112,7 +105,7 @@ bool WinMoveFile( CString sOldPath, CString sNewPath ) /* Try turning off the read-only bit on the file we're overwriting. */ SetFileAttributes( sNewPath, FILE_ATTRIBUTE_NORMAL ); - return WinMoveFileInternal( sOldPath, sNewPath ); + return WinMoveFileInternal( DoPathReplace(sOldPath), DoPathReplace(sNewPath) ); } #endif @@ -290,7 +283,7 @@ void DirectFilenameDB::PopulateFileSet( FileSet &fs, const CString &path ) } /* - * Copyright (c) 2003-2004 Glenn Maynard, Chris Danford + * Copyright (c) 2003-2005 Glenn Maynard, Chris Danford, Renaud Lepage * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/stepmania/src/RageFileDriverDirectHelpers.h b/stepmania/src/RageFileDriverDirectHelpers.h index f03a147404..e81d73ff74 100644 --- a/stepmania/src/RageFileDriverDirectHelpers.h +++ b/stepmania/src/RageFileDriverDirectHelpers.h @@ -20,6 +20,7 @@ HANDLE DoFindFirstFile( const CString &sPath, WIN32_FIND_DATA *fd ); #define DoRemove remove #define DoRmdir rmdir #endif +CString DoPathReplace( const CString &sPath ); #if defined(WIN32) bool WinMoveFile( CString sOldPath, CString sNewPath );