尝试在正在运行的文件系统上创建一个新文件并得到以下错误:


  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;
    }
}

最佳答案

-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");

关于c++ - Nacl:为***打开文件失败-5,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25725130/

10-11 23:14
查看更多