本文整理汇总了C++中common::WriteStream::write方法的典型用法代码示例。如果您正苦于以下问题:C++ WriteStream::write方法的具体用法?C++ WriteStream::write怎么用?C++ WriteStream::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::WriteStream
的用法示例。
在下文中一共展示了WriteStream::write方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: io_appendto
static void io_appendto() {
Common::String s = Common::lastPathComponent(luaL_check_string(FIRSTARG), '\\');
Common::SeekableReadStream *inFile = NULL;
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
inFile = saveFileMan->openForLoading(s);
if (!inFile) {
pushresult(0);
return;
}
int size = inFile->size();
byte *buf = new byte[size];
inFile->read(buf, size);
delete inFile;
Common::WriteStream *outFile = NULL;
outFile = saveFileMan->openForSaving(s);
if (!outFile)
pushresult(0);
else {
outFile->write(buf, size);
LuaFile *current = new LuaFile();
current->_out = outFile;
current->_filename = s;
setreturn(addfile(current), FOUTPUT);
}
delete[] buf;
}
示例2: write
bool SaveContainer::write(Common::WriteStream &stream) const {
// Write the header
if (!_header.write(stream))
return false;
// Write the part count
stream.writeUint32LE(_partCount);
// Iterate over all parts
for (PartConstIterator it = _parts.begin(); it != _parts.end(); ++it) {
// Part doesn't actually exist => error
if (!*it)
return false;
// Write the part's size
stream.writeUint32LE((*it)->size);
}
if (!flushStream(stream))
return false;
// Iterate over all parts
for (PartConstIterator it = _parts.begin(); it != _parts.end(); ++it) {
Part * const &p = *it;
// Write the part
if (stream.write(p->data, p->size) != p->size)
return false;
}
return flushStream(stream);
}
示例3: openSaveFileForReading
Common::WriteStream *ScummEngine_v60he::openSaveFileForAppending(const byte *fileName) {
Common::SeekableReadStream *initialFile = openSaveFileForReading(fileName);
byte *initialData = 0;
uint32 initialDataSize = 0;
if (initialFile) {
initialDataSize = initialFile->size();
if (initialDataSize > 0) {
initialData = new byte[initialDataSize];
initialFile->read(initialData, initialDataSize);
}
delete initialFile;
}
Common::WriteStream *output = openSaveFileForWriting(fileName);
if (!output) {
delete[] initialData;
return nullptr;
}
if (initialData) {
output->write(initialData, initialDataSize);
delete[] initialData;
}
return output;
}
示例4: writeLocString
void LocString::writeLocString(Common::WriteStream &stream, bool withNullTerminate) const {
for (StringMap::const_iterator iter = _strings.begin(); iter != _strings.end() ; iter++) {
stream.writeUint32LE((*iter).first);
stream.writeUint32LE((*iter).second.size());
stream.write((*iter).second.c_str(), (*iter).second.size());
if (withNullTerminate)
stream.writeByte(0);
}
}
示例5: saveGame
bool BladeRunnerEngine::saveGame(Common::WriteStream &stream, const Graphics::Surface &thumbnail) {
if (!playerHasControl() || _sceneScript->isInsideScript() || _aiScripts->isInsideScript()) {
return false;
}
Common::MemoryWriteStreamDynamic memoryStream(DisposeAfterUse::YES);
SaveFileWriteStream s(memoryStream);
s.write(thumbnail.getPixels(), SaveFileManager::kThumbnailSize);
s.writeFloat(1.0f);
_settings->save(s);
_scene->save(s);
_scene->_exits->save(s);
_scene->_regions->save(s);
_scene->_set->save(s);
for (uint i = 0; i != _gameInfo->getGlobalVarCount(); ++i) {
s.writeInt(_gameVars[i]);
}
_music->save(s);
// _audioPlayer->save(s) // zero func
// _audioSpeech->save(s) // zero func
_combat->save(s);
_gameFlags->save(s);
_items->save(s);
_sceneObjects->save(s);
_ambientSounds->save(s);
_overlays->save(s);
_spinner->save(s);
_scores->save(s);
_dialogueMenu->save(s);
_obstacles->save(s);
_actorDialogueQueue->save(s);
_waypoints->save(s);
for (uint i = 0; i != _gameInfo->getActorCount(); ++i) {
_actors[i]->save(s);
int animationState, animationFrame, animationStateNext, nextAnimation;
_aiScripts->queryAnimationState(i, &animationState, &animationFrame, &animationStateNext, &nextAnimation);
s.writeInt(animationState);
s.writeInt(animationFrame);
s.writeInt(animationStateNext);
s.writeInt(nextAnimation);
}
_actors[kActorVoiceOver]->save(s);
_policeMaze->save(s);
_crimesDatabase->save(s);
s.finalize();
stream.writeUint32LE(memoryStream.size() + 4);
stream.write(memoryStream.getData(), memoryStream.size());
stream.flush();
return true;
}
示例6: processData
void processData(int flushType) {
// This function is called by both write() and finalize().
while (_zlibErr == Z_OK && (_stream.avail_in || flushType == Z_FINISH)) {
if (_stream.avail_out == 0) {
if (_wrapped->write(_buf, BUFSIZE) != BUFSIZE) {
_zlibErr = Z_ERRNO;
break;
}
_stream.next_out = _buf;
_stream.avail_out = BUFSIZE;
}
_zlibErr = deflate(&_stream, flushType);
}
}
示例7: if
Common::WriteStream *KyraEngine_v1::openSaveForWriting(const char *filename, const char *saveName, const Graphics::Surface *thumbnail) const {
if (shouldQuit())
return 0;
Common::WriteStream *out = 0;
if (!(out = _saveFileMan->openForSaving(filename))) {
warning("Can't create file '%s', game not saved", filename);
return 0;
}
// Savegame version
out->writeUint32BE(MKTAG('W', 'W', 'S', 'V'));
out->writeByte(_flags.gameID);
out->writeUint32BE(CURRENT_SAVE_VERSION);
out->write(saveName, strlen(saveName) + 1);
if (_flags.isTalkie)
out->writeUint32BE(GF_TALKIE);
else if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
out->writeUint32BE(GF_FMTOWNS);
else
out->writeUint32BE(GF_FLOPPY);
if (out->err()) {
warning("Can't write file '%s'. (Disk full?)", filename);
delete out;
return 0;
}
Graphics::Surface *genThumbnail = 0;
if (!thumbnail)
thumbnail = genThumbnail = generateSaveThumbnail();
if (thumbnail)
Graphics::saveThumbnail(*out, *thumbnail);
else
Graphics::saveThumbnail(*out);
if (genThumbnail) {
genThumbnail->free();
delete genThumbnail;
}
return out;
}
示例8: finalize
void finalize() {
if (_zlibErr != Z_OK)
return;
// Process whatever remaining data there is.
processData(Z_FINISH);
// Since processData only writes out blocks of size BUFSIZE,
// we may have to flush some stragglers.
uint remainder = BUFSIZE - _stream.avail_out;
if (remainder > 0) {
if (_wrapped->write(_buf, remainder) != remainder) {
_zlibErr = Z_ERRNO;
}
}
// Finalize the wrapped savefile, too
_wrapped->finalize();
}
示例9: saveGame
bool LureEngine::saveGame(uint8 slotNumber, Common::String &caption) {
Common::WriteStream *f = this->_saveFileMan->openForSaving(
generateSaveName(slotNumber));
if (f == NULL)
return false;
f->write("lure", 5);
f->writeByte(getLanguage());
f->writeByte(LURE_SAVEGAME_MINOR);
f->writeString(caption);
f->writeByte(0); // End of string terminator
Resources::getReference().saveToStream(f);
Game::getReference().saveToStream(f);
Sound.saveToStream(f);
Fights.saveToStream(f);
Room::getReference().saveToStream(f);
delete f;
return true;
}
示例10: pngWriteToStream
void pngWriteToStream(png_structp pngPtr, png_bytep data, png_size_t length) {
void *writeIOptr = png_get_io_ptr(pngPtr);
Common::WriteStream *stream = (Common::WriteStream *)writeIOptr;
stream->write(data, length);
}
示例11:
int ObjectV2::save(Common::WriteStream &dest) {
dest.write(_objData, _objSize);
return 0;
}
示例12: testFileSystem
// This function leaks. For now I don't care
bool PspUnitTests::testFileSystem() {
// create memory
const uint32 BufSize = 32 * 1024;
char* buffer = new char[BufSize];
int i;
Common::WriteStream *wrStream;
Common::SeekableReadStream *rdStream;
PSP_INFO_PRINT("testing fileSystem...\n");
// fill buffer
for (i=0; i<(int)BufSize; i += 4) {
buffer[i] = 'A';
buffer[i + 1] = 'B';
buffer[i + 2] = 'C';
buffer[i + 3] = 'D';
}
// create a file
const char *path = "./file.test";
Common::FSNode file(path);
PSP_INFO_PRINT("creating write stream...\n");
wrStream = file.createWriteStream();
if (!wrStream) {
PSP_ERROR("%s couldn't be created.\n", path);
return false;
}
// write contents
char* index = buffer;
int32 totalLength = BufSize;
int32 curLength = 50;
PSP_INFO_PRINT("writing...\n");
while(totalLength - curLength > 0) {
if ((int)wrStream->write(index, curLength) != curLength) {
PSP_ERROR("couldn't write %d bytes\n", curLength);
return false;
}
totalLength -= curLength;
index += curLength;
//curLength *= 2;
//PSP_INFO_PRINT("write\n");
}
// write the rest
if ((int)wrStream->write(index, totalLength) != totalLength) {
PSP_ERROR("couldn't write %d bytes\n", curLength);
return false;
}
delete wrStream;
PSP_INFO_PRINT("reading...\n");
rdStream = file.createReadStream();
if (!rdStream) {
PSP_ERROR("%s couldn't be created.\n", path);
return false;
}
// seek to beginning
if (!rdStream->seek(0, SEEK_SET)) {
PSP_ERROR("couldn't seek to the beginning after writing the file\n");
return false;
}
// read the contents
char *readBuffer = new char[BufSize + 4];
memset(readBuffer, 0, (BufSize + 4));
index = readBuffer;
while (rdStream->read(index, 100) == 100) {
index += 100;
}
if (!rdStream->eos()) {
PSP_ERROR("didn't find EOS at end of stream\n");
return false;
}
// compare
for (i=0; i<(int)BufSize; i++)
if (buffer[i] != readBuffer[i]) {
PSP_ERROR("reading/writing mistake at %x. Got %x instead of %x\n", i, readBuffer[i], buffer[i]);
return false;
}
// Check for exceeding limit
for (i=0; i<4; i++) {
if (readBuffer[BufSize + i]) {
PSP_ERROR("read exceeded limits. %d = %x\n", BufSize + i, readBuffer[BufSize + i]);
}
}
delete rdStream;
//.........这里部分代码省略.........