我試圖檢查一個目錄是否存在於本機客戶端file system但找不到任何功能。我試圖爲該目錄創建一個PPB_FileRef
,然後使用PPB_FileIO::Open
打開它,然後調用PPB_FileIO::Query
,但PPB_FileIO::Open
返回PP_ERROR_NOTAFILE
,然後第二次調用失敗。檢查谷歌本地客戶端文件系統中是否存在目錄?
這是我一直在嘗試的代碼,爲簡潔起見,一些初始化被忽略。
PP_Instance instance; // initialised elsewhere
PPB_FileRef *fileRefInterface; // initialised elsewhere
PPB_FileIO *fileIOInterface; // initialised elsewhere
PP_Resource fileSystemResource; // initialised elsewhere
PP_Resource fileRefResource = fileRefInterface->Create(
fileSystemResource,
"/directory");
PP_Resource fileIOResource = fileIOInterface->Create(instance);
// This call is returning PP_ERROR_NOTAFILE
//
int32_t result = fileIOInterface->Open(
fileIOResource,
fileRefResource,
PP_FILEOPENFLAG_READ,
PP_BlockUntilComplete()); // this is being called from a background thread.
if (result != PP_OK)
{
return false;
}
PP_FileInfo info;
result = fileIOInterface->Query(fileIOResource, &info, PP_BlockUntilComplete());
if (result != PP_OK)
{
return info.type == PP_FILETYPE_DIRECTORY;
}
return false;
是PP_ERROR_NOTAFILE
從PPB_FileIO::Open
一個有效PPB_FileRef
足以讓我告訴它是一個目錄,或者是有其他更好的方法,我應該使用一個返回值?
謝謝,詹姆斯