Using fopen with the chrome apps filesystem ?

58 views
Skip to first unread message

Alexino2

unread,
Oct 30, 2015, 7:34:01 PM10/30/15
to Native-Client-Discuss
Hello,

I would like to get a file from a local disk, using the the chrome apps, and simply use fopen with it.

Actually, I can open the file with url_loader, and put it on the memfs with nacl_io, and then use fopen, but the file is copied into the memory...

Now I would like to do the same without using the memory and directly use the file from the local disk using chrome apps.

Using pp::FileSystem ? But how ?

Thanks !

Sam Clegg

unread,
Oct 31, 2015, 1:41:37 PM10/31/15
to native-cli...@googlegroups.com
You can do this by requesting access to the local filesystem form
JavaScript using the chrome.filesystem API and then passing the
filesytem reference via postMessage and mounting the filesystem using
nacl_io as an html5 filesystem.

For an example of how to do this see the libgit2-demo which is part of
naclports.

>
> Thanks !
>
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to native-client-di...@googlegroups.com.
> To post to this group, send email to native-cli...@googlegroups.com.
> Visit this group at http://groups.google.com/group/native-client-discuss.
> For more options, visit https://groups.google.com/d/optout.

Alexino2

unread,
Oct 31, 2015, 7:11:52 PM10/31/15
to Native-Client-Discuss
Le samedi 31 octobre 2015 18:41:37 UTC+1, Sam Clegg a écrit :
You can do this by requesting access to the local filesystem form
JavaScript using the chrome.filesystem API and then passing the
filesytem reference via postMessage and mounting the filesystem using
nacl_io as an html5 filesystem.

For an example of how to do this see the libgit2-demo which is part of
naclports.

 Hmm, before going to the C code, just wondering if the html5fs method recopy the file into the disk (as memfs do it with ram) or allow to point directly to the local file without any copy ?

Meaning, a 1GB file open with chrome.filesytem, will not add another 1GB using html5fs on the the local disk after ?

Thanks :)

Victor Khimenko

unread,
Oct 31, 2015, 7:36:12 PM10/31/15
to Native Client Discuss
No. html5fs gives you access to the files on the user's disk. But there's a limitation and annoyance. Limitation (understandable) is that you couldn't just go and grab random files from user's disk, file (or directory starting from Chrome 31) must be explicitly picked by user. Annoyance is ChromeOS: it does not have user-visible files and directories thus this process is a bit different there (but I don't remember the exact details).

Alexino2

unread,
Nov 1, 2015, 2:11:57 PM11/1/15
to Native-Client-Discuss
Thanks Sam for the tip !

I finally did it, this is a pretty powerful stuff,

By the way it's really strange that nacl_io.h doesn't mention anything about the filesystem resource and that there are only two exemples , only on C and naclports...

Reply all
Reply to author
Forward
0 new messages