Fixed the fs.read() example in doc. The error checking statements were using the wrong variable name (#449)
This commit is contained in:
parent
fd3de6be2c
commit
e3a1187ef9
|
@ -908,11 +908,11 @@ Example:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
fs.open('/myfile', 'r', function(err, fd) {
|
fs.open('/myfile', 'r', function(err, fd) {
|
||||||
if(err) throw error;
|
if(err) throw err;
|
||||||
|
|
||||||
// Determine size of file
|
// Determine size of file
|
||||||
fs.fstat(fd, function(err, stats) {
|
fs.fstat(fd, function(err, stats) {
|
||||||
if(err) throw error;
|
if(err) throw err;
|
||||||
|
|
||||||
// Create a buffer large enough to hold the file's contents
|
// Create a buffer large enough to hold the file's contents
|
||||||
var nbytes = expected = stats.size;
|
var nbytes = expected = stats.size;
|
||||||
|
@ -923,7 +923,7 @@ fs.open('/myfile', 'r', function(err, fd) {
|
||||||
length = length || buffer.length - read;
|
length = length || buffer.length - read;
|
||||||
|
|
||||||
fs.read(fd, buffer, offset, length, position, function(err, nbytes) {
|
fs.read(fd, buffer, offset, length, position, function(err, nbytes) {
|
||||||
if(err) throw error;
|
if(err) throw err;
|
||||||
|
|
||||||
// nbytes is now the number of bytes read, between 0 and buffer.length.
|
// nbytes is now the number of bytes read, between 0 and buffer.length.
|
||||||
// See if we still have more bytes to read.
|
// See if we still have more bytes to read.
|
||||||
|
|
Loading…
Reference in New Issue