Addons: Using Node.js FileSystem module to save and load wrapped object

29 views
Skip to first unread message

blazs

unread,
Nov 21, 2014, 2:25:20 AM11/21/14
to nod...@googlegroups.com

I am working on a linear algebra Node.js addon (written in C++) and I want to be able to save to and read from disk all objects I exposed.

For example, v = la.load(fs.open("vector.out", "r-")); would load a vector object I previously saved with v.save(fs.open("vector.out", "r+"));. (I'm making it up --- the point is I want the user to pass a Node.js object for File I/O on the Javascript side, and use that object to load/save my object on the C++ side.)

My question(s):

  1. How do I access Node.js's FileSystem objects from the C++ side? (On the Javascript side user passes a fs object to my load function and I want to extract file descriptor from that object.)
  2. How do Node.js addons typically solve this? Any tips?
  3. Examples, if available, are more than welcome. 
(Note: Reposted this from StackOverflow in the hope for any answers.)

Reply all
Reply to author
Forward
0 new messages