A friendly, nodejs-like file i/o experience for C++
#include "../fs.h"
using namespace std;
using namespace nodeuv;
int main() {
Filesystem fs;
fs.readFile("test.txt", [](auto err, auto data) {
if (err) {
cout << err.message << endl;
return;
}
cout << data << endl;
});
}
Creates a loop for file operations.
Returns a string that represents the current working directory.
Stats, Opens, reads whole file, callback provides (error
, streambuf
).
Stats, Opens, reads whole file and returns an instance of Buffer
.
Opens, writes whole buffer, callback provides (error
).
Opens, writes whole value from the instance of Buffer
.
Callback provides (error
, stats
), where stats is a struct containing
the following members...
Returns a Stats struct.
uint64_t dev;
uint64_t mode;
uint64_t nlink;
uint64_t uid;
uint64_t gid;
uint64_t rdev;
uint64_t ino;
uint64_t size;
uint64_t blksize;
uint64_t blocks;
uint64_t flags;
uint64_t gen;
uv_timespec_t atime;
uv_timespec_t mtime;
uv_timespec_t ctime;
uv_timespec_t birthtime;
Create a directory sync, optionally pass the mode as an octal. Returns an error instance that will have the value of null if the operation was successful.
Remove a direcory sync. Returns an error object that has the value of null if the operation was a success.
The callback provides two arguments Error
which will be null if the
operation was a success and a file descriptor.
Open a file sync, optionally pass the mode as an octal. Returns the file descriptor.
Callback provides (error
, uv_buf_t
).
Returns an instance of Buffer
.
Callback provides (error
, uv_buf_t
).
Write an instance of Buffer
to a file, returns the number of bytes
written.
Close a file. Callback provides an instance of Error
which is null
if the operation was a success.
Close a file sync.
A little sugar on top of uv_buf_t
. This should get moved out to
another module called nodeuv-buffer
.