本文整理汇总了C++中FileHelper::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ FileHelper::Write方法的具体用法?C++ FileHelper::Write怎么用?C++ FileHelper::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelper
的用法示例。
在下文中一共展示了FileHelper::Write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveBloomFilter
bool SnapshotControl::SaveBloomFilter(BloomFilter<Checksum>* pbf, const string& bf_name)
{
if (!FileSystemHelper::GetInstance()->IsDirectoryExists(vm_path_))
FileSystemHelper::GetInstance()->CreateDirectory(vm_path_);
if (FileSystemHelper::GetInstance()->IsFileExists(bf_name))
FileSystemHelper::GetInstance()->RemoveFile(bf_name);
FileHelper* fh = FileSystemHelper::GetInstance()->CreateFileHelper(bf_name, O_WRONLY);
fh->Create();
stringstream buffer;
pbf->Serialize(buffer);
LOG4CXX_DEBUG(logger_, "Bloom filter primary size " << buffer.str().size());
fh->Write((char *)buffer.str().c_str(), buffer.str().size());
fh->Close();
FileSystemHelper::GetInstance()->DestroyFileHelper(fh);
return true;
}
示例2: SaveSnapshotMeta
bool SnapshotControl::SaveSnapshotMeta()
{
if (!FileSystemHelper::GetInstance()->IsDirectoryExists(vm_path_))
FileSystemHelper::GetInstance()->CreateDirectory(vm_path_);
if (FileSystemHelper::GetInstance()->IsFileExists(ss_meta_pathname_)) {
LOG4CXX_WARN(logger_, "Sanpshot metadata exists, will re-create " << ss_meta_pathname_);
FileSystemHelper::GetInstance()->RemoveFile(ss_meta_pathname_);
}
FileHelper* fh = FileSystemHelper::GetInstance()->CreateFileHelper(ss_meta_pathname_, O_WRONLY);
fh->Create();
stringstream buffer;
ss_meta_.Serialize(buffer);
ss_meta_.SerializeRecipe(buffer);
LOG4CXX_DEBUG(logger_, "save snapshot meta, size is" << buffer.str().size());
fh->Write((char *)buffer.str().c_str(), buffer.str().size());
fh->Close();
FileSystemHelper::GetInstance()->DestroyFileHelper(fh);
return true;
}