Skip to content

Commit

Permalink
doc: add note for platform specific flags fs.open()
Browse files Browse the repository at this point in the history
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 22, 2016
1 parent a3b5b9c commit ae991e7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit ae991e7

Please sign in to comment.