本文整理汇总了C++中FileStream::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStream::Create方法的具体用法?C++ FileStream::Create怎么用?C++ FileStream::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileStream
的用法示例。
在下文中一共展示了FileStream::Create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoSaveGame
/** Save game to given directory */
static bool DoSaveGame(const char *Path)
{
Game *game = core->GetGame();
//saving areas to cache currently in memory
unsigned int mc = (unsigned int) game->GetLoadedMapCount();
while (mc--) {
Map *map = game->GetMap(mc);
if (core->SwapoutArea(map)) {
return false;
}
}
gamedata->SaveAllStores();
//compress files in cache named: .STO and .ARE
//no .CRE would be saved in cache
if (core->CompressSave(Path)) {
return false;
}
//Create .gam file from Game() object
if (core->WriteGame(Path)) {
return false;
}
//Create .wmp file from WorldMap() object
if (core->WriteWorldMap(Path)) {
return false;
}
PluginHolder<ImageWriter> im(PLUGIN_IMAGE_WRITER_BMP);
if (!im) {
printMessage( "SaveGameIterator", "Couldn't create the BMPWriter!\n", LIGHT_RED );
return false;
}
//Create portraits
for (int i = 0; i < game->GetPartySize( false ); i++) {
Sprite2D* portrait = core->GetGameControl()->GetPortraitPreview( i );
if (portrait) {
char FName[_MAX_PATH];
snprintf( FName, sizeof(FName), "PORTRT%d", i );
FileStream outfile;
outfile.Create( Path, FName, IE_BMP_CLASS_ID );
im->PutImage( &outfile, portrait );
}
}
// Create area preview
Sprite2D* preview = core->GetGameControl()->GetPreview();
FileStream outfile;
outfile.Create( Path, core->GameNameResRef, IE_BMP_CLASS_ID );
im->PutImage( &outfile, preview );
return true;
}
示例2: SaveStore
void GameData::SaveStore(Store* store)
{
if (!store)
return;
StoreMap::iterator it = stores.find(store->Name);
if (it == stores.end()) {
error("GameData", "Saving a store that wasn't cached.");
}
PluginHolder<StoreMgr> sm(IE_STO_CLASS_ID);
if (sm == NULL) {
error("GameData", "Can't save store to cache.");
}
FileStream str;
if (!str.Create(store->Name, IE_STO_CLASS_ID)) {
error("GameData", "Can't create file while saving store.");
}
if (!sm->PutStore(&str, store)) {
error("GameData", "Error saving store.");
}
stores.erase(it);
delete store;
}
示例3: LoadFromFile
bool Json::LoadFromFile(LPCWSTR fn,DWORD codepage){
FileStream fs;
if(!fs.Create(fn,OPEN_EXISTING)) return 0;
String buf;
fs.ReadString(buf,0,codepage);
return Parse(buf);
}
示例4: SaveToFile
bool Json::SaveToFile(LPCWSTR fn,DWORD codepage,bool readStyle){
FileStream fs;
if(!fs.Create(fn,OPEN_ALWAYS)) return 0;
fs.SetLength(0);
String buf;
ToString(buf,readStyle);
return 0!=fs.WriteString(buf,0,0,codepage);
}
示例5: FileStream
FileStream *ResourceManager::CreateCacheFile(const char *filename, SClass_ID ClassID)
{
FileStream *stream = new FileStream();
if (!stream)
return NULL;
if (!stream->Create(core->CachePath, filename, ClassID)) {
delete stream;
return NULL;
}
cacheMap.replace(filename, stream->originalfile);
return stream;
}
示例6: GetAuxTlk
DataStream* CTlkOverride::GetAuxTlk(bool create)
{
char nPath[_MAX_PATH];
PathJoin( nPath, core->CachePath, "default.tot", NULL );
FileStream* fs = new FileStream();
retry:
if (fs->Modify(nPath)) {
return fs;
}
if (create) {
fs->Create( "default", IE_TOT_CLASS_ID);
create = false;
goto retry;
}
delete fs;
return NULL;
}
示例7: DecompressBIFC
DataStream* BIFImporter::DecompressBIFC(DataStream* compressed, const char* path)
{
print( "Decompressing\n" );
if (!core->IsAvailable( PLUGIN_COMPRESSION_ZLIB ))
return NULL;
PluginHolder<Compressor> comp(PLUGIN_COMPRESSION_ZLIB);
ieDword unCompBifSize;
compressed->ReadDword( &unCompBifSize );
print( "\nDecompressing file: [..........]" );
fflush(stdout);
FileStream out;
if (!out.Create(path)) {
printMessage("BIFImporter", "Cannot write %s.\n", RED, path);
return NULL;
}
ieDword finalsize = 0;
int laststep = 0;
while (finalsize < unCompBifSize) {
ieDword complen, declen;
compressed->ReadDword( &declen );
compressed->ReadDword( &complen );
if (comp->Decompress( &out, compressed, complen ) != GEM_OK) {
return NULL;
}
finalsize = out.GetPos();
if (( int ) ( finalsize * ( 10.0 / unCompBifSize ) ) != laststep) {
laststep++;
print( "\b\b\b\b\b\b\b\b\b\b\b" );
int l;
for (l = 0; l < laststep; l++)
print( "|" );
for (; l < 10; l++)//l starts from laststep
print( "." );
print( "]" );
fflush(stdout);
}
}
print( "\n" );
out.Close(); // This is necesary, since windows won't open the file otherwise.
return FileStream::OpenFile(path);
}
示例8: GetAuxHdr
DataStream* CTlkOverride::GetAuxHdr(bool create)
{
char nPath[_MAX_PATH];
char Signature[TOH_HEADER_SIZE];
PathJoin( nPath, core->CachePath, "default.toh", NULL );
FileStream* fs = new FileStream();
retry:
if (fs->Modify(nPath)) {
return fs;
}
if (create) {
fs->Create( "default", IE_TOH_CLASS_ID);
memset(Signature,0,sizeof(Signature));
memcpy(Signature,"TLK ",4);
fs->Write(Signature, sizeof(Signature));
create = false;
goto retry;
}
delete fs;
return NULL;
}