split out GetDirOfExecutable
This commit is contained in:
@@ -64,43 +64,44 @@ public:
|
|||||||
};
|
};
|
||||||
static RageFileDriverMountpoints *g_Mountpoints = NULL;
|
static RageFileDriverMountpoints *g_Mountpoints = NULL;
|
||||||
|
|
||||||
|
static CString GetDirOfExecutable( CString argv0 )
|
||||||
static void ChangeToDirOfExecutable( CString argv0 )
|
|
||||||
{
|
{
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
DirOfExecutable = "D:\\";
|
return "D:\\";
|
||||||
InitialWorkingDirectory = "D:\\";
|
|
||||||
#else
|
#else
|
||||||
|
CString sPath = argv0;
|
||||||
char tmp[1024];
|
sPath.Replace( "\\", "/" );
|
||||||
getcwd( tmp, 1024 );
|
|
||||||
tmp[1023] = 0;
|
|
||||||
InitialWorkingDirectory = tmp;
|
|
||||||
|
|
||||||
DirOfExecutable = argv0;
|
|
||||||
DirOfExecutable.Replace( "\\", "/" );
|
|
||||||
|
|
||||||
bool IsAbsolutePath = false;
|
bool IsAbsolutePath = false;
|
||||||
if( DirOfExecutable.size() == 0 || DirOfExecutable[0] == '/' )
|
if( sPath.size() == 0 || sPath[0] == '/' )
|
||||||
IsAbsolutePath = true;
|
IsAbsolutePath = true;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if( DirOfExecutable.size() > 2 && DirOfExecutable[1] == ':' && DirOfExecutable[2] == '/' )
|
if( sPath.size() > 2 && sPath[1] == ':' && sPath[2] == '/' )
|
||||||
IsAbsolutePath = true;
|
IsAbsolutePath = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// strip off executable name
|
// strip off executable name
|
||||||
unsigned n = DirOfExecutable.find_last_of("/");
|
unsigned n = sPath.find_last_of("/");
|
||||||
if( n != DirOfExecutable.npos )
|
if( n != sPath.npos )
|
||||||
DirOfExecutable.erase(n);
|
sPath.erase(n);
|
||||||
else
|
else
|
||||||
DirOfExecutable.erase();
|
sPath.erase();
|
||||||
|
|
||||||
if( !IsAbsolutePath )
|
if( !IsAbsolutePath )
|
||||||
{
|
{
|
||||||
DirOfExecutable = GetCwd() + "/" + DirOfExecutable;
|
sPath = GetCwd() + "/" + sPath;
|
||||||
DirOfExecutable.Replace( "\\", "/" );
|
sPath.Replace( "\\", "/" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return sPath;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ChangeToDirOfExecutable( CString argv0 )
|
||||||
|
{
|
||||||
|
InitialWorkingDirectory = GetCwd();
|
||||||
|
DirOfExecutable = GetDirOfExecutable( argv0 );
|
||||||
|
|
||||||
/* Set the CWD. Any effects of this is platform-specific; most files are read and
|
/* Set the CWD. Any effects of this is platform-specific; most files are read and
|
||||||
* written through RageFile. See also RageFileManager::RageFileManager. */
|
* written through RageFile. See also RageFileManager::RageFileManager. */
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@@ -108,8 +109,6 @@ static void ChangeToDirOfExecutable( CString argv0 )
|
|||||||
#elif defined(DARWIN)
|
#elif defined(DARWIN)
|
||||||
chdir(DirOfExecutable + "/../../..");
|
chdir(DirOfExecutable + "/../../..");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RageFileManager::RageFileManager( CString argv0 )
|
RageFileManager::RageFileManager( CString argv0 )
|
||||||
|
|||||||
Reference in New Issue
Block a user