本文整理汇总了C++中COFile::close方法的典型用法代码示例。如果您正苦于以下问题:C++ COFile::close方法的具体用法?C++ COFile::close怎么用?C++ COFile::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COFile
的用法示例。
在下文中一共展示了COFile::close方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save
void CSoundAnimation::save()
{
// File stream
COFile file;
vector<NLMISC::CSheetId> sounds;
// Open the file
if (!file.open(_Filename.c_str()))
{
throw NLMISC::Exception("Can't open the file for writing");
}
// Create the XML stream
COXml output;
// Init
if (output.init (&file, "1.0"))
{
xmlDocPtr xmlDoc = output.getDocument();
// Create the first node
xmlNodePtr root = xmlNewDocNode (xmlDoc, NULL, (const xmlChar*)"SOUNDANIMATION", NULL);
xmlDocSetRootElement (xmlDoc, root);
vector<CSoundAnimMarker*>::iterator iter;
for (iter = _Markers.begin(); iter != _Markers.end(); iter++)
{
CSoundAnimMarker* marker = (*iter);
set<string>::iterator iter;
char s[64];
smprintf(s, 64, "%f", marker->getTime());
xmlNodePtr markerNode = xmlNewChild (root, NULL, (const xmlChar*)"MARKER", NULL);
xmlSetProp (markerNode, (const xmlChar*) "time", (const xmlChar*) s);
marker->getSounds(sounds);
vector<NLMISC::CSheetId>::iterator iter2;
for (iter2 = sounds.begin(); iter2 != sounds.end(); iter2++)
{
xmlNodePtr soundNode = xmlNewChild ( markerNode, NULL, (const xmlChar*)"SOUND", NULL );
xmlSetProp (soundNode, (const xmlChar*)"name", (const xmlChar*)iter2->toString().c_str() /*CStringMapper::unmap(*iter2).c_str()*/);
}
sounds.clear();
}
// Flush the stream, write all the output file
output.flush ();
}
// Close the file
file.close ();
_Dirty = false;
}
示例2: createInstanceFile
// ---------------------------------------------------------------------------
void CGeorgesImpl::createInstanceFile (const std::string &_sxFullnameWithoutExt, const std::string &_dfnname)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CFormLoader formLoader;
CFormDfn *dfn = formLoader.loadFormDfn (_dfnname.c_str(), false);
if (!dfn)
{
char msg[512];
smprintf (msg, 512, "Can't load DFN '%s'", _dfnname);
theApp.outputError (msg);
return;
}
NLMISC::CSmartPtr<NLGEORGES::UForm> Form = new CForm;
std::string fullName;
fullName = _sxFullnameWithoutExt + ".";
int i = 0;
if (_dfnname[i] == '.') ++i;
for (; i < (int)_dfnname.size(); ++i)
{
if (_dfnname[i] == '.') break;
fullName += _dfnname[i];
}
((CFormElmStruct*)&Form->getRootNode ())->build (dfn);
COFile f;
COXml ox;
if (f.open (fullName))
{
ox.init(&f);
((NLGEORGES::CForm*)((UForm*)Form))->write (ox.getDocument(), _sxFullnameWithoutExt.c_str ());
ox.flush();
f.close();
}
else
{
char msg[512];
smprintf (msg, 512, "Can't write '%s'", fullName);
theApp.outputError (msg);
return;
}
}
示例3: setDebugOutput
//-----------------------------------------------
// setDebugOutput :
// Set an output file to log debugs.
//-----------------------------------------------
void setDebugOutput(const std::string &filename)
{
// Remove output
if(filename.empty())
{
DebugFile.close();
IsDebugFile = false;
return;
}
// Open The Item Association File
if(!DebugFile.open(filename, false, true))
{
nlwarning("setDebugOutput: Cannot Open the '%s'.", filename.c_str());
IsDebugFile = false;
}
else
IsDebugFile = true;
}// setDebugOutput //
示例4: load
//-----------------------------------------------
// load :
// Load all sheets.
//-----------------------------------------------
void CSheetManager::load(NLMISC::IProgressCallback &callBack, bool updatePackedSheet, bool needComputeVS, bool dumpVSIndex)
{
// Open The Item Association File
if(!fItemAssoc.open("item_association.dbg", false, true))
nlwarning("CSheetManager::load: Cannot Open the 'item_association.txt'.");
else
ItemAssocFileOpen = true;
// Initialize the Sheet DB.
loadAllSheet(callBack, updatePackedSheet, needComputeVS, dumpVSIndex);
// Close the Item Association File.
fItemAssoc.close();
ItemAssocFileOpen = false;
// Optimize memory taken by all strings of all sheets
ClientSheetsStrings.memoryCompress();
return;
}// load //
示例5: main
//.........这里部分代码省略.........
float cellRaytraceDeltaZ= cell_raytrace_delta_z.asFloat ();
// colIdentifierPrefix
CConfigFile::CVar &col_identifier_prefix = parameter.getVar ("col_identifier_prefix");
string colIdentifierPrefix= col_identifier_prefix.asString ();
// colIdentifierSuffix
CConfigFile::CVar &col_identifier_suffix = parameter.getVar ("col_identifier_suffix");
string colIdentifierSuffix= col_identifier_suffix.asString ();
// colIdentifierSuffix
CConfigFile::CVar &build_debug_surface_shape = parameter.getVar ("build_debug_surface_shape");
bool buildDebugSurfaceShape= build_debug_surface_shape.asInt()!=0;
// try to open gr and rbank
CRetrieverBank *retrieverBank= NULL;
CGlobalRetriever *globalRetriever= NULL;
uint32 grFileDate= 0;
uint32 rbankFileDate= 0;
if( grFile!="" && rbankFile!="" )
{
CIFile fin;
// serial the retrieverBank. Exception if not found.
fin.open(CPath::lookup(rbankFile));
retrieverBank= new CRetrieverBank;
retrieverBank->setNamePrefix(CFile::getFilenameWithoutExtension(rbankFile).c_str ());
// Add the search path for LR files
CPath::addSearchPath (CFile::getPath(rbankFile));
fin.serial(*retrieverBank);
fin.close();
// serial the globalRetriever. Exception if not found.
fin.open(CPath::lookup(grFile));
globalRetriever= new CGlobalRetriever;
// set the RetrieverBank before loading
globalRetriever->setRetrieverBank(retrieverBank);
fin.serial(*globalRetriever);
fin.close();
// Get File Dates
rbankFileDate= CFile::getFileModificationDate(CPath::lookup(rbankFile));
grFileDate= CFile::getFileModificationDate(CPath::lookup(grFile));
// And init them.
globalRetriever->initAll();
}
// Scan and load all files .ig in directories
//=================
vector<string> listFile;
vector<CInstanceGroup*> listIg;
vector<string> listIgFileName;
vector<string> listIgPathName;
CPath::getPathContent(directoryIn, false, false, true, listFile);
for(uint iFile=0; iFile<listFile.size(); iFile++)
{
string &igFile= listFile[iFile];
// verify it is a .ig.
if( CFile::getExtension(igFile) == "ig" )
{
示例6: dump
//-----------------------------------------------
// dump :
// Create a file with information to debug.
//-----------------------------------------------
void dump(const std::string &name)
{
// Write information to start as the version
COFile fStart;
if(fStart.open(name + "_start.rec", false, false))
{
CVectorD currentPos = UserEntity->pos();
fStart.serialVersion(RecordVersion);
fStart.serial(currentPos);
// Close the File.
fStart.close();
}
else
nlwarning("dump: cannot open/create the file '%s_start.rec'.", name.c_str());
// Write the DB
IngameDbMngr.write(name + "_db.rec");
// Open the file.
COFile f;
if(f.open(name + ".rec", false, false))
{
// Dump entities.
EntitiesMngr.dump(f);
// Dump Client CFG.
ClientCfg.serial(f);
// Close the File.
f.close();
}
else
nlwarning("dump: cannot open/create the file '%s.rec'.", name.c_str());
// Open the file.
if(f.open(name + ".xml", false, true))
{
// Create the XML stream
COXml output;
// Init
if(output.init (&f, "1.0"))
{
// Open the XML Dump.
output.xmlPush("XML");
// Dump Client CFG.
ClientCfg.serial(output);
// Dump entities.
EntitiesMngr.dumpXML(output);
// Close the XML Dump.
output.xmlPop();
// Flush the stream, write all the output file
output.flush();
}
else
nlwarning("dump: cannot initialize '%s.xml'.", name.c_str());
// Close the File.
f.close();
}
else
nlwarning("dump: cannot open/create the file '%s.xml'.", name.c_str());
}// dump //
示例7: int
// ***************************************************************************
int main(int argc, char *argv[])
{
// Filter addSearchPath
NLMISC::createDebug();
NLMISC::InfoLog->addNegativeFilter ("adding the path");
if (argc != 3)
{
nlwarning("usage : %s hlsinfo_dir output_name ", argv[0]);
exit(-1);
}
// get all .hlsinfo file in directory.
vector<string> files;
vector<string> hlsInfofiles;
NLMISC::CPath::getPathContent(argv[1], false, false, true, files);
hlsInfofiles.reserve(files.size());
uint k;
for (k = 0; k < files.size(); ++k)
{
std::string fileExt = NLMISC::strupr(NLMISC::CFile::getExtension(files[k]));
if(fileExt=="HLSINFO")
hlsInfofiles.push_back(files[k]);
}
// If none, quit.
if(hlsInfofiles.empty())
exit(-1);
// Concat all hlsinfo in a Bank
CHLSTextureBank textBank;
for (k = 0; k < hlsInfofiles.size(); ++k)
{
printf("HLSBank Process [%2d]\r", (uint)(100*k/hlsInfofiles.size()));
try
{
CIFile f(hlsInfofiles[k]);
CHLSBankTextureInfo textInfo;
f.serial(textInfo);
addTextToBank(textInfo, textBank);
}
catch(Exception &e)
{
nlwarning("ERROR: Unable to process %s. Reason: %s. Processing next", hlsInfofiles[k].c_str(), e.what());
}
}
// compile it
textBank.compile();
// save the bank.
COFile fOut;
try
{
if(!fOut.open(argv[2]))
throw int(0);
fOut.serial(textBank);
fOut.close();
}
catch(Exception &e)
{
nlwarning("ERROR: Unable to write HLS Bank %s: %s", argv[2], e.what());
exit(-1);
}
catch(...)
{
nlwarning("ERROR: Unable to write HLS Bank %s.", argv[2]);
exit(-1);
}
return 0;
}
示例8: main
//.........这里部分代码省略.........
}
// Sample Rate.
try
{
CConfigFile::CVar &anim_sample_rate = parameter.getVar ("anim_sample_rate");
float sr= anim_sample_rate.asFloat(0);
// Consider values > 1000 as error values.
if(sr<=0 || sr>1000)
{
nlwarning("Bad \"anim_sample_rate\" value. Use Default of 30 fps.");
animationOptimizer.setSampleFrameRate(30);
}
else
{
animationOptimizer.setSampleFrameRate(sr);
}
}
catch(EUnknownVar &)
{
nlwarning("\"anim_sample_rate\" not found in the parameter file. Use Default of 30 fps.");
animationOptimizer.setSampleFrameRate(30);
}
// Scan and load all files .ig in directories
//=================
uint numSkipped= 0;
uint numBuilded= 0;
vector<string> listFile;
CPath::getPathContent(directoryIn, false, false, true, listFile);
for(uint iFile=0; iFile<listFile.size(); iFile++)
{
string &igFile= listFile[iFile];
// verify it is a .anim.
if( CFile::getExtension(igFile) == "anim" )
{
string fileNameIn= CFile::getFilename(igFile);
string fileNameOut= pathOut + fileNameIn;
// skip the file?
bool mustSkip= false;
// If File Out exist
if(CFile::fileExists(fileNameOut))
{
// If newer than file In, skip
uint32 fileOutDate= CFile::getFileModificationDate(fileNameOut);
if( fileOutDate > CFile::getFileModificationDate(igFile) )
{
mustSkip= true;
}
}
// If must process the file.
if(!mustSkip)
{
// Read the animation.
CAnimation animIn;
CIFile fin;
fin.open(CPath::lookup(igFile));
fin.serial(animIn);
// process.
CAnimation animOut;
animationOptimizer.optimize(animIn, animOut);
// Save this animation.
COFile fout;
fout.open(fileNameOut);
fout.serial(animOut);
fout.close();
numBuilded++;
}
else
{
numSkipped++;
}
// progress
printf("Anim builded: %4d. Anim Skipped: %4d\r", numBuilded, numSkipped);
}
}
// Add some info in the log.
nlinfo("Anim builded: %4d", numBuilded);
nlinfo("Anim skipped: %4d", numSkipped);
}
catch (Exception& except)
{
// Error message
nlwarning ("ERROR %s\n", except.what());
}
}
// exit.
return 0;
}