本文整理汇总了C++中DataFile::getFilename方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFile::getFilename方法的具体用法?C++ DataFile::getFilename怎么用?C++ DataFile::getFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFile
的用法示例。
在下文中一共展示了DataFile::getFilename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenericException
DataFile *DataFile::reference(const stdString &req_dirname,
const stdString &req_basename, bool for_write)
{
DataFile *datafile = 0;
stdString dirname, basename, filename;
Filename::build(req_dirname, req_basename, filename);
Filename::getDirname(filename, dirname);
Filename::getBasename(filename, basename);
#ifdef LOG_DATAFILE
LOG_MSG("reference('%s', '%s', %s)\n",
req_dirname.c_str(),
req_basename.c_str(),
(for_write ? "read/write" : "read-only"));
LOG_MSG("normalized: '%s' + '%s' = '%s')\n",
dirname.c_str(), basename.c_str(), filename.c_str());
#endif
stdList<DataFile *>::iterator i = open_data_files.begin();
for (/**/; i != open_data_files.end (); ++i)
{
datafile = *i;
if (datafile->getFilename() == filename &&
datafile->for_write == for_write)
{
#ifdef LOG_DATAFILE
LOG_MSG("DataFile %s (%c) is cached (%d)\n",
filename.c_str(),
(for_write?'W':'R'), datafile->ref_count);
#endif
datafile->reference();
// When it was put in the cache, it might
// have been a new file.
// But now it's one that already existed,
// so reset is_new_file:
datafile->is_new_file = false;
return datafile;
}
}
try
{
datafile = new DataFile(dirname, basename, filename, for_write);
datafile->reopen();
open_data_files.push_back(datafile);
return datafile;
}
catch (...)
{
if (datafile)
delete datafile;
throw GenericException(__FILE__, __LINE__, "Cannot reference '%s'",
filename.c_str());
}
}
示例2: DataFile
DataFile *DataFile::reference (const stdString &filename, bool for_write)
{
DataFile *file;
FileMap::iterator i = open_data_files.find (filename);
if (i == open_data_files.end ())
{
file = new DataFile (filename, for_write);
open_data_files.insert (FileMap::value_type (file->getFilename(), file));
}
else
{
file = i->second;
file->reference ();
}
return file;
}