Nacl:***文件打开失败-5

时间:2014-09-08 13:13:16

标签: c++ google-nativeclient

尝试在工作文件系统上创建新文件并收到此错误:

  

ERR |文件打开以进行写入失败 - 错误#:-5

以下是代码:

void MyInstance::CreateFile(int32_t /* result */) {
    if (!file_system_ready_) {
        ShowErrorMessage("File system is not open", PP_ERROR_FAILED);
        return;
         }
    pp::FileRef ref(file_system_,"foo.txt");
    pp::FileIO file(this);
    int32_t open_result =
        file.Open(ref,PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_CREATE | PP_FILEOPENFLAG_TRUNCATE, pp::BlockUntilComplete());
    if (open_result != PP_OK) {
      ShowErrorMessage("File open for write failed", open_result); //here is the error
      return;
    }
}

1 个答案:

答案 0 :(得分:1)

-5错误代码代表PP_ERROR_BADRESOURCE

could be thrown by different objects,但是,这是由于FileRef路径FileRef must contain the fullpath of the file including root不仅仅是文件的名称,如下所示:

pp::FileRef ref(file_system_,"/foo.txt");