[plugin] Node-webkit Node.js FS module

Post your completed addons to share with the community

Post » Sat Dec 08, 2012 3:53 am

In heavy development - release often, release early

File I/O is provided by simple wrappers around standard POSIX functions.

This plugin exposes sync functions

Use with absolute care, you can erase all data on your computer if you up!

Demo - reads contents of c: and returns a string representation of returned array - ok to use

Plugin


This module exposes Bunch of stuff, sync and async, this is just a small small part of everything available!

Exposed stuff:

Actions

   - renameSync

   - unlinkSync

   - mkdirSync

Expression

   - readdirSync


I tested only readdirSync, so for actions i cannot guarantee anything!
JohnnySheffield2014-01-05 23:56:48
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Thu Jan 10, 2013 6:40 pm

Does this mean I can finally create a savegame.sav in for example C:\Games\Mygame\Save DiR and write data into it? Can I load the savegame back?

So the absolutely gruesome javascript HDD-access restriction does no longer apply?
B
25
S
5
G
5
Posts: 138
Reputation: 5,638

Post » Thu Jan 10, 2013 6:54 pm

Nope...

This applies only to the node-webkit export!

If you export to .exe or mac app you can use this plugin to access file system.

Note that i threw this plugin in few hours just to show it's possible, so consider this just as a starting point to write this up even more further!

Check out http://nodejs.org/api/fs.html what's possible with this node.js module!


Cheers!
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Fri Jan 11, 2013 12:26 pm

So these functions are only for local storage then?

fs.writeSync(fd, buffer, offset, length, position)#

Synchronous version of fs.write(). Returns the number of bytes written.

:(((
B
25
S
5
G
5
Posts: 138
Reputation: 5,638

Post » Fri Jan 11, 2013 3:13 pm

Sorry, i haven't been clear!

If you export with node-webkit, this gives you full access to the file system (e.g. the game can delete the contents of your drive if you die)

If you use this plugin in the classic html5 export, it will probably break your game, or it won't do anything.


For local or webstorage use the official plugins.

Cheers!
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Sun Jan 13, 2013 4:14 pm

So to be perfectly clear: If I export my Construct 2 game with node-webkit i can code-in node.js file-access routines to create a C:\GAME\SAVES directory with
fs.mkdir(path, [mode], [callback])
then save into this directory a file called savegame.dat with
fs.writeFile(filename, data, [encoding], [callback])
and all relevant functions like append, read, etc..

So the EXE compiled with node-webkit has full access to the drive?

If this is so I only need to find an installer that installs my Construct 2 game to the user given path: for example C:\Program Files\C2Arcadegame

then file-access wise we are in the best situation.mercy2013-01-13 16:15:52
B
25
S
5
G
5
Posts: 138
Reputation: 5,638

Post » Sun Jan 13, 2013 4:42 pm

Yup, that's pretty much that!

Just to repeat myself, i really made this plugin in a hurry, if you do some changes to it (and i hope you will! :) please share, so we can improve this plugin!

Cheers!
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Mon Jan 14, 2013 6:32 pm

Wow! This is what we have been waiting for! Getting free of local-storage.

Nope, my hands are full with creating graphics and basic game code. I plan however to hire C2/js programmer[s] to do elaborate work, where needed. Then once the game is on the market making profits, release the in-house plugins as open-source.mercy2013-01-14 18:36:16
B
25
S
5
G
5
Posts: 138
Reputation: 5,638

Post » Tue Jan 15, 2013 1:21 pm

Cool, sounds like a plan!

Currently i don't need this plugin in my projects, so i won't be developing it further, but if i make a new version i plan to release it to the community!


Cheers, and good luck with your game!
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652


Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest