当前位置: 首页>>代码示例>>C++>>正文


C++ OutputFile::hasError方法代码示例

本文整理汇总了C++中OutputFile::hasError方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputFile::hasError方法的具体用法?C++ OutputFile::hasError怎么用?C++ OutputFile::hasError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OutputFile的用法示例。


在下文中一共展示了OutputFile::hasError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:Proshivalskiy,项目名称:MT6582_kernel_source,代码行数:52,代码来源:OutputFile.cpp

示例2: compile

enum Compiler::ErrorCode Compiler::compile(Script &pScript,
                                           OutputFile &pResult,
                                           llvm::raw_ostream *IRStream) {
  // Check the state of the specified output file.
  if (pResult.hasError()) {
    return kErrInvalidOutputFileState;
  }

  // Open the output file decorated in llvm::raw_ostream.
  llvm::raw_pwrite_stream *out = pResult.dup();
  if (out == nullptr) {
    return kErrPrepareOutput;
  }

  // Delegate the request.
  enum Compiler::ErrorCode err = compile(pScript, *out, IRStream);

  // Close the output before return.
  delete out;

  return err;
}
开发者ID:zeldin,项目名称:platform_frameworks_compile_libbcc,代码行数:22,代码来源:Compiler.cpp

示例3: Disassemble

DisassembleResult Disassemble(OutputFile &pOutput, const char *pTriple,
                              const char *pFuncName, const uint8_t *pFunc,
                              size_t FuncSize) {
  // Check the state of the specified output file.
  if (pOutput.hasError()) {
    return kDisassembleInvalidOutput;
  }

  // Open the output file decorated in llvm::raw_ostream.
  llvm::raw_ostream *output = pOutput.dup();
  if (output == NULL) {
    return kDisassembleFailedPrepareOutput;
  }

  // Delegate the request.
  DisassembleResult result =
      Disassemble(*output, pTriple, pFuncName, pFunc, FuncSize);

  // Close the output before return.
  delete output;

  return result;
}
开发者ID:DroidSim,项目名称:platform_frameworks_compile_libbcc,代码行数:23,代码来源:Disassembler.cpp


注:本文中的OutputFile::hasError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。