Is chrome.fileSystem used inside Google’s own client

Is it possible to use chrome.fileSystem inside NaCl ?

thanks

+5
source share
1 answer

The chrome.fileSystem API allows you to access a user's local file system through a Chrome application. This requires the user to select a directory for deployment in the application.

This file system can be transferred to the NaCl module and then used with the standard NaCl pp :: FileSystem API.

There is an example of this in the NaCl SDK in examples/tutorial/filesystem_passing . You can view the code for it here .

Here are the important parts: 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 ++:

 // 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"; 

It is important to note that all paths in this file system must have the full_path prefix. Any other treatment will fail.

+6
source

All Articles