• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ common::DumpFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中common::DumpFile的典型用法代码示例。如果您正苦于以下问题:C++ DumpFile类的具体用法?C++ DumpFile怎么用?C++ DumpFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DumpFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: packData

void MadsM4Engine::dumpFile(const char* filename, bool uncompress) {
	Common::DumpFile f;
	byte buffer[DUMP_BUFFER_SIZE];
	Common::SeekableReadStream *fileS = res()->get(filename);
	
	if (!f.open(filename))
		error("Could not open '%s' for writing", filename);

	int bytesRead = 0;
	warning("Dumping %s, size: %i\n", filename, fileS->size());

	if (!uncompress) {
		while (!fileS->eos()) {
			bytesRead = fileS->read(buffer, DUMP_BUFFER_SIZE);
			f.write(buffer, bytesRead);
		}
	} else {
		MadsPack packData(fileS);
		Common::SeekableReadStream *sourceUnc;
		for (int i = 0; i < packData.getCount(); i++) {
			sourceUnc = packData.getItemStream(i);
			debugCN(kDebugCore, "Dumping compressed chunk %i of %i, size is %i\n", i + 1, packData.getCount(), sourceUnc->size());
			while (!sourceUnc->eos()) {
				bytesRead = sourceUnc->read(buffer, DUMP_BUFFER_SIZE);
				f.write(buffer, bytesRead);
			}
			delete sourceUnc;
		}
	}

	f.close();
	res()->toss(filename);
	res()->purge();
}
开发者ID:St0rmcrow,项目名称:scummvm,代码行数:34,代码来源:m4.cpp


示例2: ExtractCdf

void GagEngine::ExtractCdf(const Common::String &a_fn)
{
	CdfArchive archive(a_fn, true);

	uint pos = a_fn.size();
	for(uint i = 0; i < a_fn.size(); ++i)
	{
		if(a_fn[i] == '.')
			pos = i;
	}

	//TODO: figure out how to create directory
	Common::String dn(ConfMan.get("path") + '/' + Common::String(a_fn.c_str(), pos) + '/');

	Common::ArchiveMemberList member_list;
	archive.listMembers(member_list);
	for(Common::ArchiveMemberList::iterator it = member_list.begin(); it != member_list.end(); ++it)
	{
		Common::ScopedPtr<Common::SeekableReadStream> stream((*it)->createReadStream());

		if(stream)
		{
			uint8 *buffer = new uint8[stream->size()];
			stream->read(buffer, stream->size());

			Common::DumpFile file;
			if(file.open(dn + (*it)->getName()))
				file.write(buffer, stream->size());

			delete [] buffer;
		}
	}
}
开发者ID:superg,项目名称:scummvm,代码行数:33,代码来源:gag.cpp


示例3: Cmd_DumpVocab

bool Debugger::Cmd_DumpVocab(int argc, const char **argv) {
	Common::DumpFile outFile;
	outFile.open("vocab.txt");

	for (uint32 i = 0; i < _vm->_game->_scene.getVocabStringsCount(); i++) {
		Common::String curId = Common::String::format("%x", i + 1);
		Common::String curVocab = _vm->_game->_scene.getVocab(i + 1);
		curVocab.toUppercase();

		for (uint j = 0; j < curVocab.size(); j++) {
			if (curVocab[j] == ' ' || curVocab[j] == '-')
				curVocab.setChar('_', j);
		}

		Common::String cur = "\tNOUN_" + curVocab + " = 0x" + curId + ",\n";

		outFile.writeString(cur.c_str());
	}

	outFile.flush();
	outFile.close();

	debugPrintf("Game vocab dumped\n");

	return true;
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:26,代码来源:debugger.cpp


示例4: cmdDumpFile

bool Debugger::cmdDumpFile(int argc, const char **argv) {
	if (argc != 2) {
		debugPrintf("Format: dumpfile <resource name>\n");
		return true;
	}

	Common::SeekableReadStream *s = _vm->_res->load(argv[1]);
	if (!s) {
		debugPrintf("Invalid resource.\n");
		return true;
	}

	byte *buffer = new byte[s->size()];
	s->read(buffer, s->size());

	Common::DumpFile dumpFile;
	dumpFile.open(argv[1]);

	dumpFile.write(buffer, s->size());
	dumpFile.flush();
	dumpFile.close();

	delete[] buffer;

	debugPrintf("Resource %s has been dumped to disk.\n", argv[1]);

	return true;
}
开发者ID:Cruel,项目名称:scummvm,代码行数:28,代码来源:debugger.cpp


示例5: Cmd_DumpFile

bool Console::Cmd_DumpFile(int argc, const char **argv) {
	if (argc != 3) {
		debugPrintf("Usage: %s <file path> <output file name>\n", argv[0]);
		return true;
	}

	Common::String filePath = argv[1];
	Common::String outFileName = argv[2];

	BaseFileManager *fileManager = BaseEngine::instance().getFileManager();
	Common::SeekableReadStream *inFile = fileManager->openFile(filePath);
	if (!inFile) {
		debugPrintf("File '%s' not found\n", argv[1]);
		return true;
	}

	Common::DumpFile *outFile = new Common::DumpFile();
	outFile->open(outFileName);

	byte *data = new byte[inFile->size()];
	inFile->read(data, inFile->size());
	outFile->write(data, inFile->size());
	outFile->finalize();
	outFile->close();
	delete[] data;

	delete outFile;
	delete inFile;

	debugPrintf("Resource file '%s' dumped to file '%s'\n", argv[1], argv[2]);
	return true;
}
开发者ID:86400,项目名称:scummvm,代码行数:32,代码来源:debugger.cpp


示例6: dumpMusic

// Dumps all of the game's music in external XMIDI *.xmi files
void dumpMusic() {
	Common::File midiFile;
	Common::DumpFile outFile;
	char outName[20];
	midiFile.open(MIDI_FILE);
	int outFileSize = 0;
	char buffer[20000];

	const int total = 155;	// maximum (SCN version)

	for (int i = 0; i < total; i++) {
		if (midiOffsets[i] == 0)
			break;

		sprintf(outName, "track%03d.xmi", i + 1);
		outFile.open(outName);

		if (i < total - 1)
			outFileSize = midiOffsets[i + 1] - midiOffsets[i] - 4;
		else
			outFileSize = midiFile.size() - midiOffsets[i] - 4;

		midiFile.seek(midiOffsets[i] + 4, SEEK_SET);

		assert(outFileSize < 20000);
		midiFile.read(buffer, outFileSize);
		outFile.write(buffer, outFileSize);

		outFile.close();
	}

	midiFile.close();
}
开发者ID:Cruel,项目名称:scummvm,代码行数:34,代码来源:music.cpp


示例7: Cmd_DumpItems

bool Debugger::Cmd_DumpItems(int argc, const char **argv) {
	InventoryObjects &objects = _vm->_game->_objects;

	Common::DumpFile outFile;
	outFile.open("items.txt");

	for (uint32 i = 0; i < objects.size(); i++) {
		Common::String curId = Common::String::format("%d", i);
		Common::String desc = _vm->_game->_scene.getVocab(objects[i]._descId);
		desc.toUppercase();

		for (uint j = 0; j < desc.size(); j++) {
			if (desc[j] == ' ' || desc[j] == '-')
				desc.setChar('_', j);
		}

		Common::String cur = "\tOBJ_" + desc + " = " + curId + ",\n";

		outFile.writeString(cur.c_str());
	}

	outFile.flush();
	outFile.close();

	debugPrintf("Game items dumped\n");

	return true;
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:28,代码来源:debugger.cpp


示例8: dumpFaceMask

bool Node::dumpFaceMask(uint16 index, int face, DirectorySubEntry::ResourceType type) {
	static const int32 kMaskSize = 640 * 640;

	byte *mask = new byte[kMaskSize];
	memset(mask, 0, kMaskSize);
	uint32 headerOffset = 0;
	uint32 dataOffset = 0;

	const DirectorySubEntry *maskDesc = _vm->getFileDescription(0, index, face, type);

	if (!maskDesc) {
		delete[] mask;
		return false;
	}

	Common::MemoryReadStream *maskStream = maskDesc->getData();

	while (headerOffset < 400) {
		int blockX = (headerOffset / sizeof(dataOffset)) % 10;
		int blockY = (headerOffset / sizeof(dataOffset)) / 10;

		maskStream->seek(headerOffset, SEEK_SET);
		dataOffset = maskStream->readUint32LE();
		headerOffset = maskStream->pos();

		if (dataOffset != 0) {
			maskStream->seek(dataOffset, SEEK_SET);

			for(int i = 63; i >= 0; i--) {
				int x = 0;
				byte numValues = maskStream->readByte();
				for (int j = 0; j < numValues; j++) {
					byte repeat = maskStream->readByte();
					byte value = maskStream->readByte();
					for (int k = 0; k < repeat; k++) {
						mask[((blockY * 64) + i) * 640 + blockX * 64 + x] = value;
						x++;
					}
				}
			}
		}
	}

	delete maskStream;

	Common::DumpFile outFile;
	outFile.open(Common::String::format("dump/%d-%d.masku_%d", index, face, type));
	outFile.write(mask, kMaskSize);
	outFile.close();
	delete[] mask;

	return true;
}
开发者ID:YakBizzarro,项目名称:residual,代码行数:53,代码来源:node.cpp


示例9: dumpFile

void dumpFile(Common::SeekableReadStream *s, const char *outName) {
	byte *buffer = new byte[s->size()];
	s->read(buffer, s->size());

	Common::DumpFile dumpFile;
	dumpFile.open(outName);

	dumpFile.write(buffer, s->size());
	dumpFile.flush();
	dumpFile.close();

	delete[] buffer;
}
开发者ID:Cruel,项目名称:scummvm,代码行数:13,代码来源:console.cpp


示例10: Cmd_DumpFile

bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
	if (argc < 2) {
		debugPrintf("Usage: %s <resource> <unpack>\n", argv[0]);
		debugPrintf("  resource: the resource name\n");
		debugPrintf("  unpack: optional, when specified, the FAB/MADSPACK compressed resource is unpacked\n");
	} else {
		Common::DumpFile outFile;
		Common::File inFile;

		if (!inFile.open(argv[1])) {
			debugPrintf("Specified resource does not exist\n");
		} else {
			outFile.open(argv[1]);
			bool unpack = ((argc >= 3) && !scumm_stricmp(argv[2], "unpack"));

			byte *data;
			int totalSize = 0;

			if (!unpack) {
				totalSize = inFile.size();
				data = new byte[totalSize];
				inFile.read(data, totalSize);
			} else {
				MadsPack dataPack(&inFile);
				int count = dataPack.getCount();
				for (int i = 0; i < count; i++) {
					totalSize += dataPack.getItem(i)._size;
				}
				data = new byte[totalSize];
				byte *ptr = data;

				for (int i = 0; i < count; i++) {
					Common::SeekableReadStream *readStream = dataPack.getItemStream(i);
					readStream->read(ptr, readStream->size());
					ptr += readStream->size();
				}
			}

			outFile.write(data, totalSize);
			outFile.flush();

			delete[] data;
			inFile.close();
			outFile.close();

			debugPrintf("File written successfully.\n");
		}
	}

	return true;
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:51,代码来源:debugger.cpp


示例11: tryToDumpLine

void tryToDumpLine(const Common::String &key,
				   Common::String &line,
				   Common::HashMap<Common::String, byte> *count,
				   Common::HashMap<Common::String, bool> *fileAlreadyUsed,
				   Common::DumpFile &output) {
	const byte numberOfExamplesPerType = 8;

	if ((*count)[key] < numberOfExamplesPerType && !(*fileAlreadyUsed)[key]) {
		output.writeString(line);
		output.writeByte('\n');
		(*count)[key]++;
		(*fileAlreadyUsed)[key] = true;
	}
}
开发者ID:lukaslw,项目名称:scummvm,代码行数:14,代码来源:utility.cpp


示例12: dumpRes

void ResMan::dumpRes(uint32 id) {
	char outn[30];
	sprintf(outn, "DUMP%08X.BIN", id);
	Common::DumpFile outf;
	if (outf.open(outn)) {
		resOpen(id);
		MemHandle *memHandle = resHandle(id);
		if (memHandle) {
			outf.write(memHandle->data, memHandle->size);
			outf.close();
		}
		resClose(id);
	}
}
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:14,代码来源:resman.cpp


示例13: dumpResourcesList

void ResourceManager::dumpResourcesList(const Common::UString &fileName) const {
	Common::DumpFile file;

	if (!file.open(fileName))
		throw Common::Exception(Common::kOpenError);

	file.writeString("                Name                 |     Size    \n");
	file.writeString("-------------------------------------|-------------\n");

	for (ResourceMap::const_iterator itName = _resources.begin(); itName != _resources.end(); ++itName) {
		for (ResourceTypeMap::const_iterator itType = itName->second.begin(); itType != itName->second.end(); ++itType) {
			if (itType->second.empty())
				continue;

			const Resource &resource = itType->second.back();

			const Common::UString &name = itName->first;
			const Common::UString  ext  = setFileType("", resource.type);
			const uint32           size = getResourceSize(resource);

			const Common::UString line =
				Common::UString::sprintf("%32s%4s | %12d\n", name.c_str(), ext.c_str(), size);

			file.writeString(line);
		}
	}

	file.flush();

	if (file.err())
		throw Common::Exception("Write error");

	file.close();
}
开发者ID:Hellzed,项目名称:xoreos,代码行数:34,代码来源:resman.cpp


示例14: dumpToFile

void DirectorySubEntry::dumpToFile(Common::SeekableReadStream &inStream, const char* room, uint32 index) {
    char fileName[255];

    switch (_type) {
    case kNumMetadata:
    case kTextMetadata:
        return; // These types are pure metadata and can't be extracted
    case kCubeFace:
    case kSpotItem:
    case kLocalizedSpotItem:
    case kFrame:
        sprintf(fileName, "dump/%s-%d-%d.jpg", room, index, _face);
        break;
    case kWaterEffectMask:
        sprintf(fileName, "dump/%s-%d-%d.mask", room, index, _face);
        break;
    case kMovie:
    case kStillMovie:
    case kDialogMovie:
    case kMultitrackMovie:
        sprintf(fileName, "dump/%s-%d.bik", room, index);
        break;
    default:
        sprintf(fileName, "dump/%s-%d-%d.%d", room, index, _face, _type);
        break;
    }


    debug("Extracted %s", fileName);

    Common::DumpFile outFile;
    if (!outFile.open(fileName))
        error("Unable to open file '%s' for writing", fileName);

    inStream.seek(_offset);

    uint8 *buf = new uint8[_size];

    inStream.read(buf, _size);
    outFile.write(buf, _size);

    delete[] buf;

    outFile.close();
}
开发者ID:timfel,项目名称:residualvm,代码行数:45,代码来源:directorysubentry.cpp


示例15: dumpResourcesList

void ResourceManager::dumpResourcesList(const Common::UString &fileName) const {
	Common::DumpFile file;

	if (!file.open(fileName))
		throw Common::Exception(Common::kOpenError);

	file.writeString("                Name                 |        Hash        |     Size    \n");
	file.writeString("-------------------------------------|--------------------|-------------\n");

	for (ResourceMap::const_iterator r = _resources.begin(); r != _resources.end(); ++r) {
		if (r->second.empty())
			continue;

		const Resource &res = r->second.back();

		const Common::UString &name = res.name;
		const Common::UString   ext = TypeMan.setFileType("", res.type);
		const uint64           hash = r->first;
		const uint32           size = getResourceSize(res);

		const Common::UString line =
			Common::UString::sprintf("%32s%4s | 0x%016llX | %12d\n", name.c_str(), ext.c_str(),
                               (unsigned long long) hash, size);

		file.writeString(line);
	}

	file.flush();

	if (file.err())
		throw Common::Exception("Write error");

	file.close();
}
开发者ID:EffWun,项目名称:xoreos,代码行数:34,代码来源:resman.cpp


示例16: writeFileContentsToFile

void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile) {
	Common::File f;
	if (!f.open(sourceFile)) {
		return;
	}

	byte* buffer = new byte[f.size()];
	f.read(buffer, f.size());

	Common::DumpFile dumpFile;
	dumpFile.open(destFile);

	dumpFile.write(buffer, f.size());
	dumpFile.flush();
	dumpFile.close();

	delete[] buffer;
}
开发者ID:lukaslw,项目名称:scummvm,代码行数:18,代码来源:utility.cpp


示例17: dump

void ArchiveReader::dump(uint resIndex) {
	int32 resourceSize = getResourceSize(resIndex);
	byte *data = new byte[resourceSize];

	Common::String fn = Common::String::format("toltecs_res.%03d", resIndex);

	openResource(resIndex);
	read(data, resourceSize);
	closeResource();

	Common::DumpFile o;
	o.open(fn);
	o.write(data, resourceSize);
	o.finalize();
	o.close();

	delete[] data;
}
开发者ID:CatalystG,项目名称:scummvm,代码行数:18,代码来源:resource.cpp


示例18: Cmd_DumpArchive

bool Console::Cmd_DumpArchive(int argc, const char **argv) {
	if (argc != 2) {
		debugPrintf("Extract all the files from a game archive.\n");
		debugPrintf("The destination folder, named 'dump', must exist.\n");
		debugPrintf("Usage :\n");
		debugPrintf("dumpArchive [archive name]\n");
		return true;
	}

	Formats::XARCArchive xarc;
	if (!xarc.open(argv[1])) {
		debugPrintf("Can't open archive with name '%s'\n", argv[1]);
		return true;
	}

	Common::ArchiveMemberList members;
	xarc.listMembers(members);

	for (Common::ArchiveMemberList::const_iterator it = members.begin(); it != members.end(); it++) {
		Common::String fileName = Common::String::format("dump/%s", it->get()->getName().c_str());

		// Open the output file
		Common::DumpFile outFile;
		if (!outFile.open(fileName)) {
			debugPrintf("Unable to open file '%s' for writing\n", fileName.c_str());
			return true;
		}

		// Copy the archive content to the output file using a temporary buffer
		Common::SeekableReadStream *inStream = it->get()->createReadStream();
		uint8 *buf = new uint8[inStream->size()];

		inStream->read(buf, inStream->size());
		outFile.write(buf, inStream->size());

		delete[] buf;
		delete inStream;
		outFile.close();

		debugPrintf("Extracted '%s'\n", it->get()->getName().c_str());
	}

	return true;
}
开发者ID:Botje,项目名称:residualvm,代码行数:44,代码来源:console.cpp


示例19: Cmd_Extract

bool Console::Cmd_Extract(int argc, const char **argv) {
	if (argc != 5) {
		DebugPrintf("Extract a file from the game's archives\n");
		DebugPrintf("Usage :\n");
		DebugPrintf("extract [room] [node id] [face number] [object type]\n");
		return true;
	}

	// Room names are uppercase
	Common::String room = Common::String(argv[1]);
	room.toUppercase();

	uint16 id = atoi(argv[2]);
	uint16 face = atoi(argv[3]);
	DirectorySubEntry::ResourceType type = (DirectorySubEntry::ResourceType) atoi(argv[4]);

	const DirectorySubEntry *desc = _vm->getFileDescription(room.c_str(), id, face, type);

	if (!desc) {
		DebugPrintf("File with room %s, id %d, face %d and type %d does not exist\n", room.c_str(), id, face, type);
		return true;
	}

	Common::MemoryReadStream *s = desc->getData();
	Common::String filename = Common::String::format("node%s_%d_face%d.%d", room.c_str(), id, face, type);
	Common::DumpFile f;
	f.open(filename);

	uint8 *buf = new uint8[s->size()];

	s->read(buf, s->size());
	f.write(buf, s->size());

	delete[] buf;

	f.close();

	delete s;

	DebugPrintf("File '%s' successfully written\n", filename.c_str());

	return true;
}
开发者ID:moshverhavikk,项目名称:grim_mouse,代码行数:43,代码来源:console.cpp


示例20: dumpFaceMask

bool Console::dumpFaceMask(uint16 index, int face, DirectorySubEntry::ResourceType type) {
	const DirectorySubEntry *maskDesc = _vm->getFileDescription("", index, face, type);

	if (!maskDesc)
		return false;

	Common::MemoryReadStream *maskStream = maskDesc->getData();

	Effect::FaceMask *mask = Effect::loadMask(maskStream);

	delete maskStream;

	Common::DumpFile outFile;
	outFile.open(Common::String::format("dump/%d-%d.masku_%d", index, face, type));
	outFile.write(mask->surface->getPixels(), mask->surface->pitch * mask->surface->h);
	outFile.close();

	delete mask;

	return true;
}
开发者ID:ComputeLinux,项目名称:residualvm,代码行数:21,代码来源:console.cpp



注:本文中的common::DumpFile类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ common::Error类代码示例发布时间:2022-05-31
下一篇:
C++ common::BlockingLoop类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap