For example... (Just the other day I was just reviewing/comparing Linux vs.
Windows nodes, what was _actually_ defined in runtime values versus what is
mentioned in the constants source)
diff constants_*linux*.s constants_*windows*.s
157d122
< S_IFBLK: 24576,
160,161d124
< S_IFIFO: 4096,
< S_IFLNK: 40960,
164,176c127,184
< S_IFSOCK: 49152,
< S_IRGRP: 32,
< S_IROTH: 4,
< S_IRUSR: 256,
< S_IRWXG: 56,
< S_IRWXO: 7,
< S_IRWXU: 448,
< S_IWGRP: 16,
< S_IWOTH: 2,
< S_IWUSR: 128,
< S_IXGRP: 8,
< S_IXOTH: 1,
< S_IXUSR: 64,
81,86c78,80
< O_APPEND: 1024,
< O_CREAT: 64,
< O_DIRECTORY: 65536,
< O_EXCL: 128,
< O_NOCTTY: 256,
< O_NOFOLLOW: 131072,
---
> O_APPEND: 8,
> O_CREAT: 256,
> O_EXCL: 1024,
88d81
< O_SYNC: 4096,
You see a whole bunch of S_* constants not defined under Windows. And
fewer O_* constants under Windows. And for the same O_* constant names,
different values, like O_CREAT is either 0x0040 or 0x0100
So a question is - after which runtime, Windows, Linux, BSD, would you
model your available names and then their values?
On Saturday, May 19, 2012 9:03:23 PM UTC-5, Isaac Schlueter wrote:
>
> The O_* constants are documented in `man 2 open`. The S_* constants
> are documented in `man 2 stat`.
>
> Note that they're also platform-dependent. For example, O_SYMLINK
> only exists on BSD systems.
>
>
> On Sat, May 19, 2012 at 11:00 PM, Adam Crabtree <[email protected]>
> wrote:
> > Howdy all,
> >
> > (Let me know if this isn't appropriate for nodejs-dev.)
> >
> > I'm attempting to porting fs to the browser in browserify via the
> FileSystem
> > API, and it looks like the fastest route is to shim the appropriate
> > process.binding('fs') and process.binding('constants'), which includes:
> >
> > // from process.binding('fs')
> > [ 'Stats',
> > 'close',
> > 'open',
> > 'read',
> > 'fdatasync',
> > 'fsync',
> > 'rename',
> > 'truncate',
> > 'rmdir',
> > 'mkdir',
> > 'sendfile',
> > 'readdir',
> > 'stat',
> > 'lstat',
> > 'fstat',
> > 'link',
> > 'symlink',
> > 'readlink',
> > 'unlink',
> > 'write',
> > 'chmod',
> > 'fchmod',
> > 'chown',
> > 'fchown',
> > 'utimes',
> > 'futimes',
> > 'StatWatcher' ]
> >
> > // from process.binding('constants')
> > {
> > O_RDONLY: 0,
> > O_WRONLY: 1,
> > O_RDWR: 2,
> > S_IFMT: 61440,
> > S_IFREG: 32768,
> > S_IFDIR: 16384,
> > S_IFCHR: 8192,
> > S_IFBLK: 24576,
> > S_IFIFO: 4096,
> > S_IFLNK: 40960,
> > S_IFSOCK: 49152,
> > O_CREAT: 512,
> > O_EXCL: 2048,
> > O_NOCTTY: 131072,
> > O_TRUNC: 1024,
> > O_APPEND: 8,
> > O_DIRECTORY: 1048576,
> > O_NOFOLLOW: 256,
> > O_SYNC: 128,
> > O_SYMLINK: 2097152
> > }
> >
> > The fs bindings seem pretty straightforward, not sure if they'll all
> > translate to the FileSystem API, but mostly if anyone would be be
> willing to
> > give information on the constants I'd be very thankful.
> >
> > Also, are these documented outside of the source?
> >
> > Cheers,
> > Adam Crabtree
> >
> > --
> > Better a little with righteousness
> > than much gain with injustice.
> > Proverbs 16:8
>