Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 11, 2021. It is now read-only.
/fstreamPublic archive

Advanced FS Streaming for Node

License

NotificationsYou must be signed in to change notification settings

npm/fstream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Like FS streams, but with stat on them, and supporting directories andsymbolic links, as well as normal files. Also, you can use this to setthe stats on a file, even if you don't change its contents, or to createa symlink, etc.

So, for example, you can "write" a directory, and it'll callmkdir. Youcan specify a uid and gid, and it'll callchown. You can specify amtime andatime, and it'll callutimes. You can call it a symlinkand provide alinkpath and it'll callsymlink.

Note that it won't automatically resolve symbolic links. So, if youcallfstream.Reader('/some/symlink') then you'll get an objectthat stats and then ends immediately (since it has no data). To followsymbolic links, do this:fstream.Reader({path:'/some/symlink', follow: true }).

There are various checks to make sure that the bytes emitted are thesame as the intended size, if the size is set.

fstream.Writer({path:"path/to/file",mode:0755,size:6}).write("hello\n").end()

This will create the directories if they're missing, and then writehello\n into the file, chmod it to 0755, and assert that 6 bytes havebeen written when it's done.

fstream.Writer({path:"path/to/file",mode:0755,size:6,flags:"a"}).write("hello\n").end()

You can pass flags in, if you want to append to a file.

fstream.Writer({path:"path/to/symlink",linkpath:"./file",SymbolicLink:true,mode:"0755"// octal strings supported}).end()

If isSymbolicLink is a function, it'll be called, and if it returnstrue, then it'll treat it as a symlink. If it's not a function, thenany truish value will make a symlink, or you can settype: 'SymbolicLink', which does the same thing.

Note that the linkpath is relative to the symbolic link location, notthe parent dir or cwd.

fstream.Reader("path/to/dir").pipe(fstream.Writer("path/to/other/dir"))

This will do likecp -Rp path/to/dir path/to/other/dir. If the otherdir exists and isn't a directory, then it'll emit an error. It'll alsoset the uid, gid, mode, etc. to be identical. In this way, it's morelikersync -a than simply a copy.

About

Advanced FS Streaming for Node

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors19


[8]ページ先頭

©2009-2025 Movatter.jp