尝试在工作文件系统上创建新文件并收到此错误:
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;
}
}
答案 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");