[Developing] NFileOps.js

I'm happy to show you my first plugin!


NFileOps.js
​




DESCRIPTION


The title says it all: this plugin allows you to work with files, using the web API, Managed Storage and native modules*** to work synch- and asynchronously!


This plugin supports UNIX systems *** and download of files, it can also execute an external application***!
The weight of this library is around 50Kb.


Download: http://forums.rpgmakerweb.com/index.php?/topic/56956-manage-files-with-nfileopsjs/


DOCUMENTATION is found in the file, and you can download the new HTML version as attachment.
Italian version can be found here with examples: http://www.rpg2s.net/forum/index.php/topic/20455-nfileopsjs-opera-con-il-file-system/


Thank you for using my plugin, report me any bug / features!


*** = Locally deployed games only. I didn't check for mobile versions. If you try to run methods that rely on Node.JS with a non-NW platform, an Exception is thrown.


TODO list in next updates:

  • Add in the asynchronous callbacks a status to inform about the operations.
  • Mobile access to local storage



NEWS: added FileOps.VirtualGetStorageSpaceLeft() and fixed some bugs; updated documentation.

View attachment NFileOps.html
You should probably add, that this only works in a Node.js environment (locally deployed game).
You should probably add, that this only works in a Node.js environment (locally deployed game).



Sorry, what do you mean with "locally"?

Anyway, my script doesn't ONLY rely on Node.JS and some of the features (Managed and Virtual Storage) work in all webkit-based.
MV games can also be deployed on a web server an accessed through the browser, in which case you won't have access to Node.js, causing your "require" lines to fail. They can also be deployed on Android/iOS, though i have no experience with that and don't know how file access is handled in this case.
MV games can also be deployed on a web server an accessed through the browser, in which case you won't have access to Node.js, causing your "require" lines to fail.



I didn't consider this, uhm. I think that I could check for "require()" and disable the features that rely on NodeJS modules.


Thank you for this.
You can use "Utils.isNwjs" for this:


/**
* Checks whether the platform is NW.js.
*
* @static
* @method isNwjs
* @return {Boolean} True if the platform is NW.js
*/
Utils.isNwjs = function() {
return typeof require === 'function' && typeof process === 'object';
};


Additionally, you can take a look at the StorageManager class, which manages savefiles and dynamically switches between local storage and the file system, depending on which environment the game is in.
Fixed. Now Nwjs methods throw exceptions if Utils.isNwjs() is false.

Additionally, you can take a look at the StorageManager class, which manages savefiles and dynamically switches between local storage and the file system, depending on which environment the game is in.



That'll be in the next update along with the newer (and better) documentation.
Sorry for double posting!


Added complete documentation with examples, fixes for common programming problems and more!


Available in HTML, as attachment!

View attachment NFileOps.html
NEWS: added FileOps.VirtualGetStorageSpaceLeft() and fixed some bugs. Updated documentation.

View attachment NFileOps.html

Original thread: https://forums.rpgmakerweb.com/threads/developing-nfileops-js.56958/