/// Get the full path to the base directory of the application. /// /// @param[out] rbSuccess True if the path was retrieved successfully, false if not. /// /// @return Application base directory path, with a trailing path separator character. static FilePath& GetMutableBaseDirectory( bool& rbSuccess ) { static FilePath baseDirectory; static bool bLocateRequested = false; static bool bLocateSuccess = false; rbSuccess = bLocateSuccess; if( !bLocateRequested ) { bLocateRequested = true; baseDirectory.Set( Helium::GetProcessPath() ); // Strip the executable file. // Strip the configuration type subdirectory (i.e. Debug, Intermediate, Release, etc.). // Strip the platform binary subdirectory (i.e. x32, x64). // Strip the "Bin" directory. baseDirectory.Set( baseDirectory.Directory() + TXT( "../../.." ) ); if( !baseDirectory.Exists() ) { baseDirectory.Clear(); return baseDirectory; } baseDirectory += TXT( "/" ); bLocateSuccess = true; rbSuccess = true; } return baseDirectory; }
TEST(Foundation, FilePath) { { String tempString; FilePath pathCopy; FilePath path( TXT( "C:/Users/Test/File.notext.ext" ) ); HELIUM_TRACE( TraceLevels::Info, TXT( "path: %s\n" ), path.c_str() ); pathCopy = path; tempString = pathCopy.Directory().c_str(); pathCopy.Set( pathCopy.Directory() ); HELIUM_ASSERT( tempString == pathCopy.c_str() ); HELIUM_TRACE( TraceLevels::Info, TXT( "directory name: %s\n" ), *tempString ); pathCopy = path; tempString = pathCopy.Filename().c_str(); pathCopy.Set( pathCopy.Filename() ); HELIUM_ASSERT( tempString == pathCopy.c_str() ); HELIUM_TRACE( TraceLevels::Info, TXT( "filename: %s\n" ), *tempString ); pathCopy = path; tempString = pathCopy.Basename().c_str(); pathCopy.Set( pathCopy.Basename() ); HELIUM_ASSERT( tempString == pathCopy.c_str() ); HELIUM_TRACE( TraceLevels::Info, TXT( "base name: %s\n" ), *tempString ); pathCopy = path; tempString = pathCopy.Extension().c_str(); pathCopy.Set( pathCopy.Extension() ); HELIUM_ASSERT( tempString == pathCopy.c_str() ); HELIUM_TRACE( TraceLevels::Info, TXT( "extension: %s\n" ), *tempString ); } { FilePath dataDirectory; HELIUM_VERIFY( FileLocations::GetDataDirectory( dataDirectory ) ); HELIUM_TRACE( TraceLevels::Debug, TXT( "Data directory: %s\n" ), dataDirectory.c_str() ); HELIUM_UNREF( dataDirectory ); FilePath userDataDirectory; HELIUM_VERIFY( FileLocations::GetUserDataDirectory( userDataDirectory ) ); HELIUM_TRACE( TraceLevels::Debug, TXT( "User data directory: %s\n" ), userDataDirectory.c_str() ); HELIUM_UNREF( userDataDirectory ); } }
void Helium::InitializeExceptionListener() { // init counting this API seems kind of silly, but we can actually get initialized from several places if ( ++g_InitCount == 1 ) { #if HELIUM_OS_WIN FilePath process ( GetProcessPath() ); // Symbol path always starts with module directory std::string symbolPath( process.Directory() ); // initialize debug symbols Helium::InitializeSymbols( symbolPath ); // from here on out, submit crash reports Helium::EnableExceptionFilter(true); // wait for an exception Helium::g_ExceptionOccurred.Set( &HandleException ); #endif } }