mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
doc: add note for platform specific flags fs.open()
Note describing platform specific differences in fs.open
E.g. fs.open('<directory>', 'a+', console.log)
Fixes: https://github.com/nodejs/node/issues/3643
PR-URL: https://github.com/nodejs/node/pull/6136
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
b6a41d6120
commit
11d71da558
1 file changed
+17
@@ -795,6 +795,23 @@ On Linux, positional writes don't work when the file is opened in append mode.
|
||||
The kernel ignores the position argument and always appends the data to
|
||||
the end of the file.
|
||||
|
||||
_Note: The behavior of `fs.open()` is platform specific for some flags. As such,
|
||||
opening a directory on OS X and Linux with the `'a+'` flag - see example below -
|
||||
will return an error. Whereas on Windows and FreeBSD a file descriptor will be
|
||||
returned._
|
||||
|
||||
```js
|
||||
// OS X and Linux
|
||||
fs.open('<directory>', 'a+', (err, fd) => {
|
||||
// => [Error: EISDIR: illegal operation on a directory, open <directory>]
|
||||
})
|
||||
|
||||
// Windows and FreeBSD
|
||||
fs.open('<directory>', 'a+', (err, fd) => {
|
||||
// => null, <fd>
|
||||
})
|
||||
```
|
||||
|
||||
## fs.openSync(path, flags[, mode])
|
||||
|
||||
* `path` {String | Buffer}
|
||||
|
||||
Reference in new issue
Block a user