Exemplo n.º 1
0
void PictureBank::loadAllPics( GfxEngine& engine )
{
  std::string aPath = AppConfig::get( AppConfig::resourcePath ).toString() + "/pics/";
  loadArchive(aPath + "pics.zip", engine );
  loadArchive(aPath + "pics_oc3.zip", engine);	
  StringHelper::debug( 0xff, "number of images loaded: %d", _d->resources.size() );
}
Exemplo n.º 2
0
// Load a specific archive collection
//  - type is ignored in the demo version
//  - use ArchiveAll to load all three cds
//  - HD.hpf is always loaded along with the selected archive(s)
//  - will remove all other archives
bool ResourceManager::loadArchive(ArchiveIndex type) {
	// Unload all archives
	reset();

	// Demo version
	if (_isDemo)
		return loadArchive(archiveDemoPath);

	// Load HD
	if (!loadArchive(archiveHDPath))
		return false;

	switch(type) {
	case kArchiveCd1:
		return loadArchive(archiveCD1Path);

	case kArchiveCd2:
		return loadArchive(archiveCD2Path);

	case kArchiveCd3:
		return loadArchive(archiveCD3Path);

	case kArchiveAll:
	default:
		if (loadArchive(archiveCD1Path))
			if (loadArchive(archiveCD2Path))
				return loadArchive(archiveCD3Path);
		break;
	}

	return false;
}
PassRefPtr<WebArchiveAndroid> WebArchiveAndroid::create(SharedBuffer* buffer)
{
    const char* const noBaseUrl = "";
    const char* const defaultEncoding = 0;
    const int noParserOptions = 0;

    xmlDocPtr doc = xmlReadMemory(buffer->data(), buffer->size(), noBaseUrl, defaultEncoding, noParserOptions);
    if (!doc) {
        LOGD("create: Failed to parse document.");
        return createArchiveForError();
    }

    xmlNodePtr root = xmlDocGetRootElement(doc);
    if (!root) {
        LOGD("create: Empty document.");
        xmlFreeDoc(doc);
        return createArchiveForError();
    }

    RefPtr<WebArchiveAndroid> archive = loadArchive(root);
    if (!archive) {
        LOGD("create: Failed to load archive.");
        xmlFreeDoc(doc);
        return createArchiveForError();
    }

    xmlFreeDoc(doc);
    return archive.release();
}
Exemplo n.º 4
0
void PictureBank::loadWaitPics()
{
  std::string aPath = AppConfig::get( AppConfig::resourcePath ).toString() + "/pics/";
  loadArchive(aPath+"pics_wait.zip");

  StringHelper::debug( 0xff, "number of images loaded: %d", _d->resources.size() );
}
//----------------------------------------------------------------------------
BOOL CDockingPaletteDoc::OnOpenDocument(LPCTSTR lpszPathName,LPCTSTR lpszPaneName){
//----------------------------------------------------------------------------
	PROC_TRACE;


   if (IsModified())
		TRACE("Warning: OnOpenDocument replaces an unsaved document.\n");

	CFileException fe;
	CFile* pFile = GetFile(lpszPathName,
		CFile::modeRead|CFile::shareDenyWrite, &fe);
	if (pFile == NULL)
	{
		ReportSaveLoadException(lpszPathName, &fe,
			FALSE, AFX_IDP_FAILED_TO_OPEN_DOC);
		return FALSE;
	}

	DeleteContents();
	SetModifiedFlag();  

	CArchive loadArchive(pFile, CArchive::load | CArchive::bNoFlushOnDelete);
	loadArchive.m_pDocument = this;
	loadArchive.m_bForceFlat = FALSE;
	TRY
	{
		CWaitCursor wait;
		if (pFile->GetLength() != 0)
			Serialize(loadArchive);     // load me
		loadArchive.Close();
		ReleaseFile(pFile, FALSE);
	}
	CATCH_ALL(e)
	{
		ReleaseFile(pFile, TRUE);
		DeleteContents();   // remove failed contents

		TRY
		{
			ReportSaveLoadException(lpszPathName, e,
				FALSE, AFX_IDP_FAILED_TO_OPEN_DOC);
		}
		END_TRY
		return FALSE;
	}
	END_CATCH_ALL

	SetModifiedFlag(FALSE);     // start off with unmodified
	m_documentName = lpszPaneName;
	return TRUE;
}
Exemplo n.º 6
0
bool Resource::loadPakFile(Common::String name, Common::ArchiveMemberPtr file) {
	name.toUppercase();

	if (_archiveFiles.hasArchive(name) || _protectedFiles.hasArchive(name))
		return true;

	Common::Archive *archive = loadArchive(name, file);
	if (!archive)
		return false;

	_archiveFiles.add(name, archive, 0, false);

	return true;
}
Exemplo n.º 7
0
bool Resource::loadProtectedFiles(const char * const * list) {
	for (uint i = 0; list[i]; ++i) {
		Common::ArchiveMemberPtr file = _files.getMember(list[i]);
		if (!file)
			error("Couldn't find PAK file '%s'", list[i]);

		Common::Archive *archive = loadArchive(list[i], file);
		if (archive)
			_protectedFiles.add(list[i], archive, 0, false);
		else
			error("Couldn't load PAK file '%s'", list[i]);
	}

	return true;
}
Exemplo n.º 8
0
bool mainWindow::offlineUpdate()
{
    QString updateFileName = QFileDialog::getOpenFileName(this,
                                   tr("Select Update File"), ".",
                                   tr("yadsa update file (*.yadsa)"));
    if(updateFileName.isEmpty())
    return true;
    std::ifstream updateFile(qPrintable(updateFileName),std::ios::in | std::ios::binary);
    std::ofstream targetFile(dbFilePath,std::ios::in | std::ios::binary | std::ios::app);
    if(!updateFile || !targetFile)
    {
        updateError();
        return false;
    }
    updateFile.seekg(0,std::ios::end);
    if(updateFile.tellg()==0)
    {
        updateError();
        return false;
    }
    updateFile.seekg(0);
    //to add check for confirming valid update file
    disc a;
    while(updateFile.read((char *) &a, sizeof(a)))
               {
                    soft b;
                    targetFile.write((char *) &a, sizeof(a));
                    for(int i=0;i<a.count;i++)
                    {
                         updateFile.read((char *) &b, sizeof(b));
                         targetFile.write((char *) &b, sizeof(b));
                    }
               }

    updateFile.close();
    targetFile.close();
    QMessageBox::information(this,tr("Success"),tr("Update successful<br />Reloading Archive..."));
    loadArchive();
    return true;
}
Exemplo n.º 9
0
void COleDocument::LoadFromStorage()
{
	ASSERT(m_lpRootStg != NULL);

	// open Contents stream
	COleStreamFile file;
	CFileException fe;
	if (!file.OpenStream(m_lpRootStg, _T("Contents"),
			CFile::modeRead|CFile::shareExclusive, &fe) &&
		!file.CreateStream(m_lpRootStg, _T("Contents"),
			CFile::modeRead|CFile::shareExclusive|CFile::modeCreate, &fe))
	{
		if (fe.m_cause == CFileException::fileNotFound)
			AfxThrowArchiveException(CArchiveException::badSchema);
		else
			AfxThrowFileException(fe.m_cause, fe.m_lOsError);
	}

	// load it with CArchive (loads from Contents stream)
	CArchive loadArchive(&file, CArchive::load | CArchive::bNoFlushOnDelete);
	loadArchive.m_pDocument = this;
	loadArchive.m_bForceFlat = FALSE;

	TRY
	{
		if (file.GetLength() != 0)
			Serialize(loadArchive);     // load main contents
		loadArchive.Close();
		file.Close();
	}
	CATCH_ALL(e)
	{
		file.Abort();   // will not throw an exception
		DeleteContents();   // removed failed contents
		NO_CPP_EXCEPTION(loadArchive.Abort());
		THROW_LAST();
	}
	END_CATCH_ALL
}
//----------------------------------------------------------------------------
bool vesKiwiViewerApp::loadDatasetWithCustomBehavior(const std::string& filename)
{
  if (vtksys::SystemTools::GetFilenameName(filename) == "spl_pnl_brain_atlas.kiwi") {
    return loadBrainAtlas(filename);
  }
  else if (vtksys::SystemTools::GetFilenameName(filename) == "can_simulation.kiwi") {
    return loadCanSimulation(filename);
  }
  else if (vtksys::SystemTools::GetFilenameName(filename) == "nasa-blue-marble.kiwi") {
    return loadBlueMarble(filename);
  }
  else if (vtksys::SystemTools::GetFilenameLastExtension(filename) == ".kiwi") {
    return loadKiwiScene(filename);
  }
  else if (vtksys::SystemTools::GetFilenameLastExtension(filename) == ".pvwebgl") {
    return loadPVWebDataSet(filename);
  }
  else if (vtksys::SystemTools::GetFilenameLastExtension(filename) == ".zip"
           || vtksys::SystemTools::GetFilenameLastExtension(filename) == ".gz") {
    return loadArchive(filename);
  }

  return false;
}
static PassRefPtr<WebArchiveAndroid> loadArchive(xmlNodePtr archiveNode)
{
    xmlNodePtr resourceNode = 0;

    PassRefPtr<ArchiveResource> mainResource;
    Vector<PassRefPtr<ArchiveResource> > subresources;
    Vector<PassRefPtr<Archive> > subframes;

    if (!xmlStrEqual(archiveNode->name, archiveTag)) {
        LOGD("loadArchive: Malformed archive.");
        return 0;
    }

    for (resourceNode = archiveNode->xmlChildrenNode;
         resourceNode;
         resourceNode = resourceNode->next) {
        if (xmlStrEqual(resourceNode->name, mainResourceTag)) {
            resourceNode = resourceNode->xmlChildrenNode;
            if (!resourceNode)
                break;
            mainResource = loadArchiveResource(resourceNode);
            break;
        }
    }
    if (!mainResource) {
        LOGD("loadArchive: Failed to load main resource.");
        return 0;
    }

    for (resourceNode = archiveNode->xmlChildrenNode;
         resourceNode;
         resourceNode = resourceNode->next) {
        if (xmlStrEqual(resourceNode->name, subresourcesTag)) {
            for (resourceNode = resourceNode->xmlChildrenNode;
                 resourceNode;
                 resourceNode = resourceNode->next) {
                PassRefPtr<ArchiveResource> subresource = loadArchiveResource(resourceNode);
                if (!subresource) {
                    LOGD("loadArchive: Failed to load subresource.");
                    break;
                }
                subresources.append(subresource);
            }
            break;
        }
    }

    for (resourceNode = archiveNode->xmlChildrenNode;
         resourceNode;
         resourceNode = resourceNode->next) {
        if (xmlStrEqual(resourceNode->name, subframesTag)) {
            for (resourceNode = resourceNode->xmlChildrenNode;
                 resourceNode;
                 resourceNode = resourceNode->next) {
                PassRefPtr<WebArchiveAndroid> subframe = loadArchive(resourceNode);
                if (!subframe) {
                    LOGD("loadArchive: Failed to load subframe.");
                    break;
                }
                subframes.append(subframe);
            }
            break;
        }
    }

    return WebArchiveAndroid::create(mainResource, subresources, subframes);
}
Exemplo n.º 12
0
/******************************************************************************************
BOOL CIntChessDoc::OnOpenDocument(LPCTSTR lpszPathName)
作者      : tangjs520       创建日期: 2004-9-29
函数名    : CIntChessDoc::OnOpenDocument
返回值    : BOOL
参数列表  : 
  参数1: LPCTSTR lpszPathName
描述      : 
调用关系  : 
被调用关系: 
备注      : 
修改记录  : 
******************************************************************************************/
BOOL CIntChessDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
    // TODO: Add your specialized creation code here
    if (IsModified())
    {
        TRACE0("Warning: OnOpenDocument replaces an unsaved document.\n");
    }

    BOOL bRet = TRUE;

    CFileException fe;
    CFile* pFile = GetFile(lpszPathName, CFile::modeRead | CFile::shareDenyWrite, &fe);
    if (NULL == pFile)
    {
        ReportSaveLoadException(lpszPathName, &fe, FALSE, AFX_IDP_FAILED_TO_OPEN_DOC);
        return FALSE;
    }

    DeleteContents();
    SetModifiedFlag();  // dirty during de-serialize

    CArchive loadArchive(pFile, CArchive::load | CArchive::bNoFlushOnDelete);
    loadArchive.m_pDocument = this;
    loadArchive.m_bForceFlat = FALSE;
    try
    {
        CWaitCursor wait;
        if (pFile->GetLength() != 0)
        {
            bRet = CChessRule::Open(loadArchive);   // load me
        }
        loadArchive.Close();
        ReleaseFile(pFile, FALSE);
    }
    catch (CException* e)
    {
        //读取棋局文件发生异常,应将用户模式还原为默认模式,即手动模式
        //否则用户将无法正常关闭应用程序
        CChessRule::SetUserMode(MANUALMODE);
        SetModifiedFlag(TRUE);

        ASSERT(e->IsKindOf(RUNTIME_CLASS(CException)));
        UNUSED(e);

        ReleaseFile(pFile, TRUE);
        DeleteContents();   // remove failed contents

        try
        {
            ReportSaveLoadException(lpszPathName, e, FALSE, AFX_IDP_FAILED_TO_OPEN_DOC);
        }
        catch (CException* e)
        {
            ASSERT(e->IsKindOf(RUNTIME_CLASS(CException)));
            e->Delete();
        }

        e->Delete();

        return FALSE;
    }

    SetModifiedFlag(!bRet);     // start off with unmodified

    return bRet;
}
Exemplo n.º 13
0
void Operation::archive_sound(ScenarioRunner* sr) { loadArchive(sr,"sound"); }
Exemplo n.º 14
0
void Operation::archive_music(ScenarioRunner* sr) { loadArchive(sr,"music"); }
Exemplo n.º 15
0
bool Resource::reset() {
	unloadAllPakFiles();

	Common::FSNode dir(ConfMan.get("path"));

	if (!dir.exists() || !dir.isDirectory())
		error("invalid game path '%s'", dir.getPath().c_str());

	if (_vm->game() == GI_KYRA1) {
		// We only need kyra.dat for the demo.
		if (_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie)
			return true;

		if (!_vm->gameFlags().isDemo && _vm->gameFlags().isTalkie) {
			// List of files in the talkie version, which can never be unload.
			static const char * const list[] = {
				"ADL.PAK", "CHAPTER1.VRM", "COL.PAK", "FINALE.PAK", "INTRO1.PAK", "INTRO2.PAK",
				"INTRO3.PAK", "INTRO4.PAK", "MISC.PAK", "SND.PAK", "STARTUP.PAK", "XMI.PAK",
				"CAVE.APK", "DRAGON1.APK", "DRAGON2.APK", "LAGOON.APK", 0
			};

			loadProtectedFiles(list);
		} else {
			Common::ArchiveMemberList files;

			_files.listMatchingMembers(files, "*.PAK");
			_files.listMatchingMembers(files, "*.APK");

			for (Common::ArchiveMemberList::const_iterator i = files.begin(); i != files.end(); ++i) {
				Common::String name = (*i)->getName();
				name.toUppercase();

				// No PAK file
				if (name == "TWMUSIC.PAK")
					continue;

				// We need to only load the script archive for the language the user specified
				if (name == ((_vm->gameFlags().lang == Common::EN_ANY) ? "JMC.PAK" : "EMC.PAK"))
					continue;

				Common::Archive *archive = loadArchive(name, *i);
				if (archive)
					_files.add(name, archive, 0, false);
				else
					error("Couldn't load PAK file '%s'", name.c_str());
			}
		}
	} else if (_vm->game() == GI_KYRA2) {
		if (_vm->gameFlags().useInstallerPackage)
			_files.add("installer", loadInstallerArchive("WESTWOOD", "%03d", 6), 2, false);

		// mouse pointer, fonts, etc. required for initialization
		if (_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie) {
			loadPakFile("GENERAL.PAK");
		} else {
			loadPakFile("INTROGEN.PAK");
			loadPakFile("OTHER.PAK");
		}
	} else if (_vm->game() == GI_KYRA3) {
		if (_vm->gameFlags().useInstallerPackage) {
			if (!loadPakFile("WESTWOOD.001"))
				error("Couldn't load file: 'WESTWOOD.001'");
		}

		if (!loadFileList("FILEDATA.FDT"))
			error("Couldn't load file: 'FILEDATA.FDT'");
	} else if (_vm->game() == GI_LOL) {
		if (_vm->gameFlags().useInstallerPackage)
			_files.add("installer", loadInstallerArchive("WESTWOOD", "%d", 0), 2, false);

		if (!_vm->gameFlags().isTalkie && !_vm->gameFlags().isDemo) {
			static const char * const list[] = {
				"GENERAL.PAK", 0
			};

			loadProtectedFiles(list);
		}
	} else {
		error("Unknown game id: %d", _vm->game());
		return false;	// for compilers that don't support NORETURN
	}

	return true;
}
Exemplo n.º 16
0
//Archive
void Operation::archive_graphics(ScenarioRunner* sr) { loadArchive(sr,"graphics"); }
Exemplo n.º 17
0
CZipArchive::CZipArchive(const  core::string&name):IArchive(name),m_zipDir(0){
	loadArchive();
}