Abstraction/package for local file actions: save, saveas, open


#1

It is not a problem to write and read local files from electron.

However, to create the typical behaviour for actions like save, save as and open, several states need to be managed and checks need to take place (like: “has the file changed”, “has the file ever been saved?” etc).

Is any fellow member aware of a package/library/code snippet that capsules these and exposes an API to be used by custom code?


#2

Well, its all node (io.js) so I would assume someone has built an abstraction to Node’s fs module. It doesn’t need to be electron specific. Dang, now I’m curious.


#3

I thought so too. But despite some research I did not find any.

There are libraries like pkgloud but they seem not to manage the states – they are more saving adaptors to different backends (among them files)


#4

The Atom’s code for saving/opening shows what needs to be considered for these functions (however, the file has some code not related to this).
It uses the fs-plus package that has quite useful extensions/helpers for nodes fs functionality.


#5

I created a basic script for electron that does abstract open/save/saveas/new.
It certainly can be improved, so if you have any suggestions or pull requests…