Beispiel #1
0
static status_t
ext2_read_dir(fs_volume *_volume, fs_vnode *_node, void *_cookie,
	struct dirent *dirent, size_t bufferSize, uint32 *_num)
{
	DirectoryIterator *iterator = (DirectoryIterator *)_cookie;
	Volume* volume = (Volume*)_volume->private_volume;

	uint32 maxCount = *_num;
	uint32 count = 0;

	while (count < maxCount && bufferSize > sizeof(struct dirent)) {

		size_t length = bufferSize - sizeof(struct dirent) + 1;
		ino_t id;

		status_t status = iterator->GetNext(dirent->d_name, &length, &id);
		if (status == B_ENTRY_NOT_FOUND)
			break;

		if (status == B_BUFFER_OVERFLOW) {
			// the remaining name buffer length was too small
			if (count == 0)
				return B_BUFFER_OVERFLOW;
			break;
		}

		if (status != B_OK)
			return status;

		status = iterator->Next();
		if (status != B_OK && status != B_ENTRY_NOT_FOUND)
			return status;

		dirent->d_dev = volume->ID();
		dirent->d_ino = id;
		dirent->d_reclen = sizeof(struct dirent) + length;

		bufferSize -= dirent->d_reclen;
		dirent = (struct dirent*)((uint8*)dirent + dirent->d_reclen);
		count++;
	}

	*_num = count;
	return B_OK;
}
Beispiel #2
0
///////////////////////////////////////////////////////////////////////////////
// Called after OnInitCmdLine.  The base class handles the /help command line
// switch and exits.  If we get this far, we need to parse the command line
// and determine what mode to launch the app in.
//
bool App::OnInit()
{
    SetVendorName( HELIUM_APP_NAME );

#if !HELIUM_RELEASE && !HELIUM_PROFILE
    HELIUM_TRACE_SET_LEVEL( TraceLevels::Debug );
    Helium::InitializeSymbols();
#endif

    // Initialize sibling dynamically loaded modules.
    Helium::FilePath path ( Helium::GetProcessPath() );
    for ( DirectoryIterator itr ( FilePath( path.Directory() ) ); !itr.IsDone(); itr.Next() )
    {
        std::string ext = itr.GetItem().m_Path.Extension();
        if ( ext == HELIUM_MODULE_EXTENSION )
        {
            ModuleHandle module = LoadModule( itr.GetItem().m_Path.c_str() );
            HELIUM_ASSERT( module != HELIUM_INVALID_MODULE );
        }
    }

    // don't spend a lot of time updating idle events for windows that don't need it
    wxUpdateUIEvent::SetMode( wxUPDATE_UI_PROCESS_SPECIFIED );
    wxIdleEvent::SetMode( wxIDLE_PROCESS_SPECIFIED );

    Helium::FilePath exePath( GetProcessPath() );
    Helium::FilePath iconFolder( exePath.Directory() + TXT( "Icons/" ) );

    wxInitAllImageHandlers();
    wxImageHandler* curHandler = wxImage::FindHandler( wxBITMAP_TYPE_CUR );
    if ( curHandler )
    {
        // Force the cursor handler to the end of the list so that it doesn't try to
        // open TGA files.
        wxImage::RemoveHandler( curHandler->GetName() );
        curHandler = NULL;
        wxImage::AddHandler( new wxCURHandler );
    }

    ArtProvider* artProvider = new ArtProvider();
    wxArtProvider::Push( artProvider );

    wxSimpleHelpProvider* helpProvider = new wxSimpleHelpProvider();
    wxHelpProvider::Set( helpProvider );

    // Make sure various module-specific heaps are initialized from the main thread before use.
    InitEngineJobsDefaultHeap();
    InitGraphicsJobsDefaultHeap();

    // Register shutdown for general systems.
    m_InitializerStack.Push( FileLocations::Shutdown );
    m_InitializerStack.Push( Name::Shutdown );
    m_InitializerStack.Push( AssetPath::Shutdown );

    // Async I/O.
    AsyncLoader& asyncLoader = AsyncLoader::GetStaticInstance();
    HELIUM_VERIFY( asyncLoader.Initialize() );
    m_InitializerStack.Push( AsyncLoader::DestroyStaticInstance );

    // Asset cache management.
    FilePath baseDirectory;
    if ( !FileLocations::GetBaseDirectory( baseDirectory ) )
    {
        HELIUM_TRACE( TraceLevels::Error, TXT( "Could not get base directory." ) );
        return false;
    }

    HELIUM_VERIFY( CacheManager::InitializeStaticInstance( baseDirectory ) );
    m_InitializerStack.Push( CacheManager::DestroyStaticInstance );

    // libs
    Editor::PerforceWaitDialog::EnableWaitDialog( true );
    m_InitializerStack.Push( Perforce::Initialize, Perforce::Cleanup );
    m_InitializerStack.Push( Reflect::ObjectRefCountSupport::Shutdown );
    m_InitializerStack.Push( Asset::Shutdown );
    m_InitializerStack.Push( AssetType::Shutdown );
    m_InitializerStack.Push( Reflect::Initialize, Reflect::Cleanup );
    m_InitializerStack.Push( Editor::Initialize,  Editor::Cleanup );

    // Asset loader and preprocessor.
    HELIUM_VERIFY( LooseAssetLoader::InitializeStaticInstance() );
    m_InitializerStack.Push( LooseAssetLoader::DestroyStaticInstance );

    AssetLoader* pAssetLoader = AssetLoader::GetStaticInstance();
    HELIUM_ASSERT( pAssetLoader );

    AssetPreprocessor* pAssetPreprocessor = AssetPreprocessor::CreateStaticInstance();
    HELIUM_ASSERT( pAssetPreprocessor );
    PlatformPreprocessor* pPlatformPreprocessor = new PcPreprocessor;
    HELIUM_ASSERT( pPlatformPreprocessor );
    pAssetPreprocessor->SetPlatformPreprocessor( Cache::PLATFORM_PC, pPlatformPreprocessor );

    m_InitializerStack.Push( AssetPreprocessor::DestroyStaticInstance );
    m_InitializerStack.Push( ThreadSafeAssetTrackerListener::DestroyStaticInstance );
    m_InitializerStack.Push( AssetTracker::DestroyStaticInstance );

    m_InitializerStack.Push( InitializeEditorSystem, DestroyEditorSystem );

    //HELIUM_ASSERT( g_EditorSystemDefinition.Get() ); // TODO: Figure out why this sometimes doesn't load
    Helium::Components::Initialize( g_EditorSystemDefinition.Get() );
    m_InitializerStack.Push( Components::Cleanup );

    // Engine configuration.
    Config& rConfig = Config::GetStaticInstance();
    rConfig.BeginLoad();
    while( !rConfig.TryFinishLoad() )
    {
        pAssetLoader->Tick();
    }

    m_InitializerStack.Push( Config::DestroyStaticInstance );

    ConfigPc::SaveUserConfig();

    LoadSettings();

    Connect( wxEVT_CHAR, wxKeyEventHandler( App::OnChar ), NULL, this );

    m_Frame = new MainFrame( m_SettingsManager );

#if HELIUM_OS_WIN
    m_Engine.Initialize( &m_Frame->GetSceneManager(), GetHwndOf( m_Frame ) );
#else
    m_Engine.Initialize( &m_Frame->GetSceneManager(), NULL );
#endif

    HELIUM_VERIFY( m_Frame->Initialize() );
    m_Frame->Show();

    if ( GetSettingsManager()->GetSettings< EditorSettings >()->GetReopenLastProjectOnStartup() )
    {
        const std::vector< std::string >& mruPaths = wxGetApp().GetSettingsManager()->GetSettings<EditorSettings>()->GetMRUProjects();
        if ( !mruPaths.empty() )
        {
            FilePath projectPath( *mruPaths.rbegin() );
            if ( projectPath.Exists() )
            {
                m_Frame->OpenProject( FilePath( *mruPaths.rbegin() ) );
            }
        }
    }

    return true;
}