Anthony Bobenrieth
Anthony Bobenrieth

Reputation: 2884

Nacl: File open for *** failed -5

Trying to create a new file on a working filesystem and getting this error:

ERR|File open for write failed -- Error #: -5

Here is the code:

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

Upvotes: 0

Views: 249

Answers (1)

Anthony Bobenrieth
Anthony Bobenrieth

Reputation: 2884

The -5 error code stand for a PP_ERROR_BADRESOURCE.

It could be thrown by different objects, but here, it's due to the FileRef path. FileRef must contain the fullpath of the file including root not simply the name of the file, like this:

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

Upvotes: 1

Related Questions