本文整理汇总了C++中common::DumpFile::finalize方法的典型用法代码示例。如果您正苦于以下问题:C++ DumpFile::finalize方法的具体用法?C++ DumpFile::finalize怎么用?C++ DumpFile::finalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::DumpFile
的用法示例。
在下文中一共展示了DumpFile::finalize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: saveTimestamps
void DefaultSaveFileManager::saveTimestamps(Common::HashMap<Common::String, uint32> ×tamps) {
Common::DumpFile f;
Common::String filename = concatWithSavesPath(TIMESTAMPS_FILENAME);
if (!f.open(filename, true)) {
warning("DefaultSaveFileManager: failed to open '%s' file to save timestamps", filename.c_str());
return;
}
for (Common::HashMap<Common::String, uint32>::iterator i = timestamps.begin(); i != timestamps.end(); ++i) {
Common::String data = i->_key + Common::String::format(" %u\n", i->_value);
if (f.write(data.c_str(), data.size()) != data.size()) {
warning("DefaultSaveFileManager: failed to write timestamps data into '%s'", filename.c_str());
return;
}
}
f.flush();
f.finalize();
f.close();
}
示例4: dump
void ArchiveReader::dump(uint resIndex, const char *prefix) {
int32 resourceSize = getResourceSize(resIndex);
byte *data = new byte[resourceSize];
Common::String fn;
if (prefix)
fn = Common::String::format("%s_%04X.0", prefix, resIndex);
else
fn = Common::String::format("%04X.0", resIndex);
openResource(resIndex);
read(data, resourceSize);
closeResource();
Common::DumpFile o;
o.open(fn);
o.write(data, resourceSize);
o.finalize();
o.close();
delete[] data;
}
示例5: doit
void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
_position = position;
// Now init audio and sync resource
uint32 audioNumber = ((noun & 0xff) << 24) | ((verb & 0xff) << 16) | ((cond & 0xff) << 8) | (seq & 0xff);
#ifndef DEBUG_PORTRAIT_USE_SYNC_RESOURCES
ResourceId raveResourceId = ResourceId(kResourceTypeRave, resourceId, noun, verb, cond, seq);
Resource *raveResource = _resMan->findResource(raveResourceId, true);
uint raveOffset = 0;
#else
ResourceId syncResourceId = ResourceId(kResourceTypeSync36, resourceId, noun, verb, cond, seq);
Resource *syncResource = _resMan->findResource(syncResourceId, true);
uint syncOffset = 0;
#endif
#ifdef DEBUG_PORTRAIT
// prints out the current lip sync ASCII data
char debugPrint[4000];
if (raveResource->size < 4000) {
memcpy(debugPrint, raveResource->data, raveResource->size);
debugPrint[raveResource->size] = 0; // set terminating NUL
debug("kPortrait: using actor %s", _resourceName.c_str());
debug("kPortrait (noun %d, verb %d, cond %d, seq %d)", noun, verb, cond, seq);
debug("kPortrait: rave data is '%s'", debugPrint);
}
#endif
// TODO: maybe try to create the missing sync resources for low-res KQ6 out of the rave resources
#ifdef DEBUG_PORTRAIT_USE_SYNC_RESOURCES
// Dump the sync resources to disk
Common::DumpFile *outFile = new Common::DumpFile();
Common::String outName = syncResourceId.toPatchNameBase36() + ".sync36";
outFile->open(outName);
syncResource->writeToStream(outFile);
outFile->finalize();
outFile->close();
ResourceId raveResourceId = ResourceId(kResourceTypeRave, resourceId, noun, verb, cond, seq);
Resource *raveResource = _resMan->findResource(raveResourceId, true);
outName = raveResourceId.toPatchNameBase36() + ".rave";
outFile->open(outName);
raveResource->writeToStream(outFile);
outFile->finalize();
outFile->close();
_resMan->unlockResource(raveResource);
delete outFile;
#endif
// Set the portrait palette
_palette->set(&_portraitPalette, false, true);
// Draw base bitmap
drawBitmap(0);
bitsShow();
// Start playing audio...
_audio->stopAudio();
_audio->startAudio(resourceId, audioNumber);
#ifndef DEBUG_PORTRAIT_USE_SYNC_RESOURCES
if (!raveResource) {
warning("kPortrait: no rave resource %d %X", resourceId, audioNumber);
return;
}
// Do animation depending on rave resource till audio is done playing
int16 raveTicks;
uint16 raveID;
byte *raveLipSyncData;
byte raveLipSyncTicks;
byte raveLipSyncBitmapNr;
int timerPosition = 0;
int timerPositionWithin = 0;
int curPosition;
SciEvent curEvent;
bool userAbort = false;
while ((raveOffset < raveResource->size) && (!userAbort)) {
// rave string starts with tick count, followed by lipSyncID, tick count and so on
raveTicks = raveGetTicks(raveResource, &raveOffset);
if (raveTicks < 0)
break;
// get lipSyncID
raveID = raveGetID(raveResource, &raveOffset);
if (raveID) {
raveLipSyncData = raveGetLipSyncData(raveID);
} else {
raveLipSyncData = NULL;
}
#ifdef DEBUG_PORTRAIT
if (raveID & 0x0ff) {
debug("kPortrait: rave '%c%c' after %d ticks", raveID >> 8, raveID & 0x0ff, raveTicks);
} else if (raveID) {