Skip to content
Permalink
Browse files

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: #3643
PR-URL: #6136
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
eljefedelrodeodeljefe authored and jasnell committed Apr 21, 2016
1 parent a3b5b9c commit ae991e757732aad13af1a4b2ecf66840937f04e1
Showing with 17 additions and 0 deletions.
  1. +17 −0 doc/api/fs.md
@@ -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}

0 comments on commit ae991e7

Please sign in to comment.
You can’t perform that action at this time.