To be short and exact, I want to have this:
if ops.sftp?
fs = require('wrapper/sftp')(credentials)
if ops.ftp?
fs = require('wrapper/ftp')(credentials)
if ops.local?
fs = require('wrapper/fs')(credentials)
fs.doSameThing()
instead of this:
if ops.sftp?
sftp = new require('mscdex/ssh2')(credentials)
sftp.doSameThing()
if ops.ftp?
ftp = require('sergi/jsftp')(credentials)
ftp.doSameThingInOtherWay()
if ops.local?
fs = require('fs')(credentials)
fs.doSameThingThirdWay()
and I'd like to create a wrapper library for this, but I'm strongly against inventing another one filesystem API.
I also don't want to mess with file descriptors, file pointers, streaming and other things. I want a simple API for moving, copying, renaming, chmodding, chowning, unlinking, writing and reading the files. Is there any advice you can give to me before I start reinventing the wheel?