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

Nacl: File open for *** failed -5

本文关键字:文件 失败 Nacl      更新时间:2023-10-16

试图在工作文件系统上创建一个新文件并得到以下错误:

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。

它可以由不同的对象抛出,但这里是由于FileRef路径。FileRef必须包含文件的完整路径,包括root,而不仅仅是文件名,如下所示:

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