Google chrome chrome.fileSystem在google原生客户端中可用吗
是否可以在Google chrome chrome.fileSystem在google原生客户端中可用吗,google-chrome,google-chrome-extension,google-chrome-app,google-nativeclient,Google Chrome,Google Chrome Extension,Google Chrome App,Google Nativeclient,是否可以在NaCl内部使用chrome.fileSystem 感谢您允许您通过Chrome应用程序访问用户的本地文件系统。这需要用户选择一个目录以向应用程序公开 该文件系统可以传递到NaCl模块,然后与标准naclapi一起使用 NaCl SDK中有一个例子,位于examples/tutorial/filesystem\u。您可以浏览代码来查找它 以下是重要部分: JavaScript: chrome.fileSystem.chooseEntry({type: 'openDirectory'},
NaCl
内部使用chrome.fileSystem
感谢您允许您通过Chrome应用程序访问用户的本地文件系统。这需要用户选择一个目录以向应用程序公开
该文件系统可以传递到NaCl模块,然后与标准naclapi一起使用
NaCl SDK中有一个例子,位于examples/tutorial/filesystem\u
。您可以浏览代码来查找它
以下是重要部分:
JavaScript:
chrome.fileSystem.chooseEntry({type: 'openDirectory'}, function(entry) {
if (!entry) {
// The user cancelled the dialog.
return;
}
// Send the filesystem and the directory path to the NaCl module.
common.naclModule.postMessage({
filesystem: entry.filesystem,
fullPath: entry.fullPath
});
});
C++:
//从JavaScript获取消息。我们假设这是一本有
//两个要素:
// {
//文件系统:,
//完整路径:
// }
pp::VarDictionary var_dict(var_消息);
pp::Resource filesystem_Resource=var_dict.Get(“文件系统”).AsResource();
pp::文件系统(文件系统资源);
std::string full_path=var_dict.Get(“fullPath”).AsString();
std::string save_path=full_path+“/hello_from_nacl.txt”;
std::string contents=“你好,来自本机客户端!\n”;
需要注意的是,此文件系统中的所有路径都必须以full_path作为前缀。任何其他访问都会失败。我的猜测是“可能不会”,但看到您可以访问HTML5文件系统,最坏的情况下,您可以复制到那里使用它。但我对这个话题还不太了解。@Xan谢谢你的评论!
// Got a message from JavaScript. We're assuming it is a dictionary with
// two elements:
// {
// filesystem: <A Filesystem var>,
// fullPath: <A string>
// }
pp::VarDictionary var_dict(var_message);
pp::Resource filesystem_resource = var_dict.Get("filesystem").AsResource();
pp::FileSystem filesystem(filesystem_resource);
std::string full_path = var_dict.Get("fullPath").AsString();
std::string save_path = full_path + "/hello_from_nacl.txt";
std::string contents = "Hello, from Native Client!\n";