コード例 #1
0
ファイル: FileLocations.cpp プロジェクト: foolhuang/Helium
/// Get the full path to the base directory in which user data is stored.
///
/// @param[out] rbSuccess  True if the path was retrieved successfully, false if not.
///
/// @return  User data directory path, with a trailing path separator character.
static FilePath& GetMutableUserDataDirectory( bool& rbSuccess )
{
    static FilePath userDataDirectory;
    static bool bLocateRequested = false;
    static bool bLocateSuccess = false;

    rbSuccess = bLocateSuccess;

    if( !bLocateRequested )
    {
        bLocateRequested = true;

        tstring gameDataDirectory = Helium::GetAppDataDirectory();
		if ( gameDataDirectory.empty() )
        {
            return userDataDirectory;
        }

        String subDirectory ( GetProcessName().c_str() );
        userDataDirectory.Set( gameDataDirectory + TXT( "/" ) + subDirectory.GetData() );
        if( !userDataDirectory.MakePath() )
        {
            userDataDirectory.Clear();
            return userDataDirectory;
        }

        userDataDirectory += TXT( "/" );
        bLocateSuccess = true;
        rbSuccess = true;
    }

    return userDataDirectory;
}
コード例 #2
0
ファイル: FileLocations.cpp プロジェクト: foolhuang/Helium
/// 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;
}
コード例 #3
0
ファイル: FileLocations.cpp プロジェクト: foolhuang/Helium
/// Get the full path to the base directory in which data files are stored.
///
/// @param[out] rbSuccess  True if the path was retrieved successfully, false if not.
///
/// @return  Data directory path, with a trailing path separator character.
static FilePath& GetMutableDataDirectory( bool& rbSuccess )
{
    static FilePath dataDirectory;
    static bool bLocateRequested = false;
    static bool bLocateSuccess = false;

    rbSuccess = bLocateSuccess;

    if( !bLocateRequested )
    {
        bLocateRequested = true;

        // Get the application base directory.
        bool bBaseDirectorySuccess;
        dataDirectory = GetMutableBaseDirectory( bBaseDirectorySuccess );
        if( !bBaseDirectorySuccess )
        {
            dataDirectory.Clear();

            return dataDirectory;
        }

        dataDirectory += TXT( "Data" );
        if( !dataDirectory.Exists() )
        {
            dataDirectory.Clear();

            return dataDirectory;
        }

        dataDirectory += TXT( "/" );
        bLocateSuccess = true;
        rbSuccess = true;
    }

    return dataDirectory;
}