1 Like FS streams, but with stat on them, and supporting directories and
2 symbolic links, as well as normal files. Also, you can use this to set
3 the stats on a file, even if you don't change its contents, or to create
6 So, for example, you can "write" a directory, and it'll call `mkdir`. You
7 can specify a uid and gid, and it'll call `chown`. You can specify a
8 `mtime` and `atime`, and it'll call `utimes`. You can call it a symlink
9 and provide a `linkpath` and it'll call `symlink`.
11 Note that it won't automatically resolve symbolic links. So, if you
12 call `fstream.Reader('/some/symlink')` then you'll get an object
13 that stats and then ends immediately (since it has no data). To follow
14 symbolic links, do this: `fstream.Reader({path:'/some/symlink', follow:
17 There are various checks to make sure that the bytes emitted are the
18 same as the intended size, if the size is set.
24 .Writer({ path: "path/to/file"
32 This will create the directories if they're missing, and then write
33 `hello\n` into the file, chmod it to 0755, and assert that 6 bytes have
34 been written when it's done.
38 .Writer({ path: "path/to/file"
47 You can pass flags in, if you want to append to a file.
51 .Writer({ path: "path/to/symlink"
54 , mode: "0755" // octal strings supported
59 If isSymbolicLink is a function, it'll be called, and if it returns
60 true, then it'll treat it as a symlink. If it's not a function, then
61 any truish value will make a symlink, or you can set `type:
62 'SymbolicLink'`, which does the same thing.
64 Note that the linkpath is relative to the symbolic link location, not
65 the parent dir or cwd.
69 .Reader("path/to/dir")
70 .pipe(fstream.Writer("path/to/other/dir"))
73 This will do like `cp -Rp path/to/dir path/to/other/dir`. If the other
74 dir exists and isn't a directory, then it'll emit an error. It'll also
75 set the uid, gid, mode, etc. to be identical. In this way, it's more
76 like `rsync -a` than simply a copy.