Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading a directory #10962

Closed
s0m3on3 opened this issue Jan 23, 2017 · 6 comments
Closed

Reading a directory #10962

s0m3on3 opened this issue Jan 23, 2017 · 6 comments
Labels
doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. good first issue Issues that are suitable for first-time contributors.

Comments

@s0m3on3
Copy link

s0m3on3 commented Jan 23, 2017

  • Version: 7.4.0
  • Subsystem: fs

If you try to read a directory, the behavior will be platform specific:

// linux/windows/os x
fs.readFileSync("node_modules");
// -> Error: EISDIR: illegal operation on a directory, read

// freebsd
fs.readFileSync("node_modules");
// -> <Buffer 03 00 00 ... >

Is it ok? I expected the same result on all platforms

@addaleax addaleax added freebsd Issues and PRs related to the FreeBSD platform. fs Issues and PRs related to the fs subsystem / file system. question Issues that look for answers. labels Jan 23, 2017
@joyeecheung
Copy link
Member

Looks like a doc issue? The docs of fs.open does mention this platform-specific behavior.

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. In contrast, on Windows and FreeBSD, a file descriptor
will be returned.

// 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>
});

@joyeecheung joyeecheung added the doc Issues and PRs related to the documentations. label Jan 23, 2017
@bnoordhuis bnoordhuis removed the freebsd Issues and PRs related to the FreeBSD platform. label Jan 24, 2017
@TimothyGu TimothyGu added good first issue Issues that are suitable for first-time contributors. and removed question Issues that look for answers. labels Mar 20, 2017
@Dean-Coakley
Copy link
Contributor

Dumb question - So what exactly should be done about this? 😅

To me it seems the docs already explain the differences quite explicitly, so I don't see what is to be done?

@addaleax
Copy link
Member

Dumb question - So what exactly should be done about this?

Definitely not a dumb question. I guess the two options are “close this as working as expected” or “add a note to the readFile(Sync) documentation too”, and I’d personally be okay with either.

@thelostone-mc
Copy link
Contributor

@addaleax Would pull request 12800 seem alright ?

thelostone-mc added a commit to thelostone-mc/node that referenced this issue May 5, 2017
Updated fs.md stating fs.readFileAsync is platform specific

Refs: nodejs#10962
refack pushed a commit that referenced this issue May 5, 2017
* Updated fs.md stating fs.readFileAsync is platform specific
* Fix formatting of `note`s

PR-URL: #12800
Refs: #10962
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
anchnk pushed a commit to anchnk/node that referenced this issue May 6, 2017
* Updated fs.md stating fs.readFileAsync is platform specific
* Fix formatting of `note`s

PR-URL: nodejs#12800
Refs: nodejs#10962
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
gibfahn pushed a commit that referenced this issue Jun 18, 2017
* Updated fs.md stating fs.readFileAsync is platform specific
* Fix formatting of `note`s

PR-URL: #12800
Refs: #10962
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
gibfahn pushed a commit that referenced this issue Jun 20, 2017
* Updated fs.md stating fs.readFileAsync is platform specific
* Fix formatting of `note`s

PR-URL: #12800
Refs: #10962
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@matejkrajcovic
Copy link
Contributor

@addaleax Could this be closed? It's already fixed in #12800.

@bnoordhuis
Copy link
Member

Yes, I'll close. Cheers.

MylesBorins pushed a commit that referenced this issue Jul 11, 2017
* Updated fs.md stating fs.readFileAsync is platform specific
* Fix formatting of `note`s

PR-URL: #12800
Refs: #10962
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. good first issue Issues that are suitable for first-time contributors.
Projects
None yet
Development

No branches or pull requests

8 participants