Skip to content

Commit 11d71da

Browse files
eljefedelrodeodeljefejasnell
authored andcommitted
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>
1 parent b6a41d6 commit 11d71da

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/api/fs.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,23 @@ On Linux, positional writes don't work when the file is opened in append mode.
795795
The kernel ignores the position argument and always appends the data to
796796
the end of the file.
797797

798+
_Note: The behavior of `fs.open()` is platform specific for some flags. As such,
799+
opening a directory on OS X and Linux with the `'a+'` flag - see example below -
800+
will return an error. Whereas on Windows and FreeBSD a file descriptor will be
801+
returned._
802+
803+
```js
804+
// OS X and Linux
805+
fs.open('<directory>', 'a+', (err, fd) => {
806+
// => [Error: EISDIR: illegal operation on a directory, open <directory>]
807+
})
808+
809+
// Windows and FreeBSD
810+
fs.open('<directory>', 'a+', (err, fd) => {
811+
// => null, <fd>
812+
})
813+
```
814+
798815
## fs.openSync(path, flags[, mode])
799816

800817
* `path` {String | Buffer}

0 commit comments

Comments
 (0)