Esempio n. 1
0
/// 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;
}
Esempio n. 2
0
/// 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;
}
Esempio n. 3
0
void FileDialogButtonWidget::OnClicked( const Inspect::FileDialogButtonClickedArgs& args )
{
    HELIUM_ASSERT( m_ButtonWindow );

    long windowStyle = 0;
    switch ( args.m_Type )
    {
    case Inspect::FileDialogTypes::OpenFile:
        windowStyle = wxFD_OPEN;
        break;
    case Inspect::FileDialogTypes::SaveFile:
        windowStyle = wxFD_SAVE;
        break;
    default:
        HELIUM_BREAK();
        break;
    }

    FilePath path;
    wxFileDialog fileDialog( m_ButtonWindow->GetParent(), args.m_Caption.c_str(), args.m_StartPath.Directory().c_str(), args.m_StartPath.Filename().c_str(), args.m_Filter.c_str(), windowStyle );
    if ( fileDialog.ShowModal() == wxID_OK )
    {
        path.Set( static_cast<const char*>( fileDialog.GetPath().c_str() ) );
    }

    args.m_Result = path;
}
Esempio n. 4
0
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 );
    }

}