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

Already on GitHub? Sign in to your account

Included example on how to use fs.read() #3190

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
6 participants

This example shows to how to use fs.read() with a buffer.

It also shows how to use fs.open() and fs.close()

@bnoordhuis bnoordhuis commented on the diff Apr 30, 2012

doc/api/fs.markdown
@@ -341,6 +341,36 @@ If `position` is `null`, data will be read from the current file position.
The callback is given the three arguments, `(err, bytesRead, buffer)`.
+ var fs = require('fs');
+ var fileName = __dirname + '/test.txt';
+
+ // Create the test file (this is sync on purpose)
+ fs.writeFileSync(fileName, 'five guys named moe', 'utf8');
+
+ // Read async
+ fs.open(fileName, 'r', function(err, fd) {
+ var content = new Buffer("123456789", "utf8");
+ if(err) {
@bnoordhuis

bnoordhuis Apr 30, 2012

Owner

Style issue: space between if and parenthesis. Happens again a few lines below.

Another style issue is that code examples should use two space indent.

Owner

bnoordhuis commented Apr 30, 2012

Hector, can you sign the CLA?

Can one of the admins verify this patch?

@hectorcorrea interest in updating the styles and signing the CLA to get this in?

It's easy enough to fix the styling issue. Need two things:

  1. @hectorcorrea you'll need to sign the CLA
  2. Since these are so old, want these examples to be run again to make sure they actually still work.

I'm going to close this, would certainly entertain documentation patches in the future.

@tjfontaine tjfontaine closed this Feb 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment