本文整理汇总了C++中OutputFile::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputFile::getName方法的具体用法?C++ OutputFile::getName怎么用?C++ OutputFile::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputFile
的用法示例。
在下文中一共展示了OutputFile::getName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: err
OutputFile *OutputFile::CreateTemporary(const std::string &pFileTemplate,
unsigned pFlags) {
char *tmp_filename = NULL;
int tmp_fd;
OutputFile *result = NULL;
// Allocate memory to hold the generated unique temporary filename.
tmp_filename =
new (std::nothrow) char [ pFileTemplate.length() + /* .XXXXXX */7 + 1 ];
if (tmp_filename == NULL) {
ALOGE("Out of memory when allocates memory for filename %s in "
"OutputFile::CreateTemporary()!", pFileTemplate.c_str());
return NULL;
}
// Construct filename template for mkstemp().
if (pFileTemplate.length() > 0)
::memcpy(tmp_filename, pFileTemplate.c_str(), pFileTemplate.length());
::strncpy(tmp_filename + pFileTemplate.length(), ".XXXXXX", 7);
// POSIX mkstemp() never returns EINTR.
tmp_fd = ::mkstemp(tmp_filename);
if (tmp_fd < 0) {
llvm::error_code err(errno, llvm::posix_category());
ALOGE("Failed to create temporary file using mkstemp() for %s! (%s)",
tmp_filename, err.message().c_str());
delete [] tmp_filename;
return NULL;
}
// Create result OutputFile. Temporary file is always truncated.
result = new (std::nothrow) OutputFile(tmp_filename,
pFlags | FileBase::kTruncate);
if (result == NULL) {
ALOGE("Out of memory when creates OutputFile for %s!", tmp_filename);
// Fall through to the clean-up codes.
} else {
if (result->hasError()) {
ALOGE("Failed to open temporary output file %s! (%s)",
result->getName().c_str(), result->getErrorMessage().c_str());
delete result;
result = NULL;
// Fall through to the clean-up codes.
}
}
// Clean up.
delete [] tmp_filename;
::close(tmp_fd);
return result;
}