ybbkrishna / npapi-file-io

Automatically exported from code.google.com/p/npapi-file-io
0 stars 0 forks source link

Usage example #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I haven’t found any docs at all.

I came here from 
http://groups.google.com/a/chromium.org/group/chromium-extensions/browse_frm/thr
ead/0372dfd06d94f55a/63a422b834ccb36a#63a422b834ccb36a. I wonder, does it 
provide JS API such as the following or not?

<embed type="application/x-my-extension" id="fs"> 
<script> 
  var fs = document.getElementById("fs"); 
  fs.writeFile("/Users/nv/dummy.txt", "bla-blah", function(err) { 
    if (!err) console.log("Hooray!"); 
  }); 
</script>

Original issue reported on code.google.com by alter.EL...@gmail.com on 10 Feb 2012 at 12:51

GoogleCodeExporter commented 9 years ago
From looking at the source, it is a synchronous api, so you would do something 
like that.

    plugin.saveTextFile("C://foo/bar.txt", "Hello World");

Since it is cross platform between Windows/Linux (no NPAPI entry point for 
Mac), you can get the platform by doing 

   getPlatform() === 'windows'

Something along those lines. Tne plugin entry points are available here:
http://code.google.com/p/npapi-file-io/source/browse/trunk/src/cpp/npapi-file-io
/npapi-file-io.cpp

Original comment by m0.inter...@gmail.com on 10 Feb 2012 at 1:11

GoogleCodeExporter commented 9 years ago
Thanks, saveTextFile is what I was looking for. If only it worked on Mac...

Original comment by alter.EL...@gmail.com on 10 Feb 2012 at 1:40

GoogleCodeExporter commented 9 years ago
Given that packing and/or using this plugin incorrectly gives every web page in 
the world read/write access to every file on the computer of a user who 
installs an extension using it, correct usage guidelines with giant warnings 
about what not to do would be a really good idea.

Original comment by stuart.morgan on 22 Feb 2012 at 3:57