Ejemplo n.º 1
0
void CMapFileFinderBase::DeleteAndNullPathComponents()
{
    DeleteAndNull(iTargetPath);
    DeleteAndNull(iFileName);
    DeleteAndNull(iFileExt);
    DeleteAndNull(iNameAndExt);
}
Ejemplo n.º 2
0
CMapFileFinderBase::~CMapFileFinderBase()
{
    DeleteAndNullPathComponents();
    if (iFileList) {
        iFileList->Reset();
        delete iFileList;
    }
    if (iDirList) {
        iDirList->Reset();
        delete iDirList;
    }
    delete iFinder;
    iFinder = NULL;
    DeleteAndNull(iFinder);
    DeleteAndNull(iFileMan);
    Cancel();
}
Ejemplo n.º 3
0
/**
 * Deallocates and shuts down game
 */
void SpringApp::Shutdown()
{
	if (gu) gu->globalQuit = true;

#define DeleteAndNull(x) delete x; x = NULL;

	GML::Exit();
	DeleteAndNull(pregame);
	DeleteAndNull(game);
	DeleteAndNull(gameServer);
	DeleteAndNull(gameSetup);
	CLoadScreen::DeleteInstance();
	ISound::Shutdown();
	DeleteAndNull(font);
	DeleteAndNull(smallFont);
	CNamedTextures::Kill();
	GLContext::Free();
	GlobalConfig::Deallocate();
	ConfigHandler::Deallocate();
	UnloadExtensions();

	IMouseInput::FreeInstance(mouseInput);
	KeyInput::FreeInstance(keyInput);

	SDL_WM_GrabInput(SDL_GRAB_OFF);
#if !defined(HEADLESS)
	SDL_QuitSubSystem(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_JOYSTICK);
#endif
	SDL_Quit();

	DeleteAndNull(gs);
	DeleteAndNull(gu);
	DeleteAndNull(globalRendering);
	DeleteAndNull(startsetup);

	FileSystemInitializer::Cleanup();

	Watchdog::Uninstall();

#ifdef USE_MMGR
	m_dumpMemoryReport();
#endif
}
Ejemplo n.º 4
0
TInt CMapFileFinderBase::InitializeDirListL(const MDesCArray* aDirList)
{
    // Initialize iDirList, copy all elements from
    // aDirList to iDirList.
    if (iDirList) {
        iDirList->Reset();
        DeleteAndNull(iDirList);
    }
    iDirList = new (ELeave) CDesCArrayFlat(aDirList->MdcaCount());
    for (TInt i = 0; i < aDirList->MdcaCount(); i++) {
        iDirList->AppendL(aDirList->MdcaPoint(i));
    }
    return KErrNone;
}
Ejemplo n.º 5
0
void CMapFileFinderBase::InternalFindFilesL()
{
    if (!iFileList) {
        iFileList = new (ELeave) CDesCArrayFlat(5);
    }
    if (iDirList && iDirList->Count() > 0) {
        TPtrC path = iDirList->MdcaPoint(0);
        CDir* dir;
        TInt err = iFinder->FindWildByDir(*iNameAndExt, path, dir);
        if (path != KNullDesC && err == KErrNone) {
            while (err == KErrNone) {
                // We have found at least one match in path.
                class TParse parser;
                for(TInt i=0; i<dir->Count(); i++) {
                    // Iterate through dir and check all matching files.
                    parser.Set(dir->operator[](i).iName,
                               &iFinder->File(), NULL);
                    TPtrC path = parser.FullName();
                    if(CheckFile(path)) {
                        // The file is a real map file, add it to
                        // our list.
                        iFileList->AppendL(path);
                    }
                }
                DeleteAndNull(dir);
                err = iFinder->FindWild(dir);
            }
        }
        if (iFirstFile) {
            iFirstFile = EFalse;
        }
        iDIState = EMoveFiles;
    } else {
        // No more directories to search in, we are
        // finished.
        iDIState = EFindAndMoveFilesRequestCompleted;
    }
    CompleteRequest(KErrNone);
}
Ejemplo n.º 6
0
void CMapFileFinderBase::FindAndMoveFilesL(const MDesCArray& aDirList,
        const TDesC& aTargetPath,
        const TDesC& aFileName,
        const TDesC& aFileExt)
{
    if (isRunning) {
        // Already running, requester needs to wait until
        // we are finished.
        iDIState = ERequestDenied;
        CompleteRequest(KErrNone);
    } else {
        // DeleteAndNull on all pointer member.
        // Initialize members.
        iFirstFile = ETrue;
        SetRunning(ETrue);
        iNbrFoundFiles = 0;
        DeleteAndNullPathComponents();
        InitializeDirListL(&aDirList);
        if (iFileList) {
            iFileList->Reset();
            DeleteAndNull(iFileList);
        }
        iTargetPath = aTargetPath.AllocL();
        iFileName   = aFileName.AllocL();
        iFileExt    = aFileExt.AllocL();
        _LIT(KDot, ".");
        iNameAndExt = HBufC::NewL(aFileName.Size() + aFileExt.Size() + 1);
        iNameAndExt->Des().Copy(aFileName);
        iNameAndExt->Des().Append(KDot);
        iNameAndExt->Des().Append(aFileExt);
        if (!iFinder) {
            iFinder  = new (ELeave) TFindFile(iFs);
        }
        iDIState = EFindFiles;
        CompleteRequest(KErrNone);
    }
}