Fixes issue #32
This commit is contained in:
parent
04d6db164e
commit
676e210fc4
2 changed files with 8 additions and 1 deletions
|
|
@ -369,6 +369,10 @@ exports.LineReader = function(filename, bufferSize) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.LineReader.prototype = {
|
exports.LineReader.prototype = {
|
||||||
|
close: function() {
|
||||||
|
return fs.closeSync(this.fd);
|
||||||
|
},
|
||||||
|
|
||||||
getBufferAndSetCurrentPosition: function(position) {
|
getBufferAndSetCurrentPosition: function(position) {
|
||||||
var res = fs.readSync(this.fd, this.bufferSize, position, "ascii");
|
var res = fs.readSync(this.fd, this.bufferSize, position, "ascii");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ var f = new wrench.LineReader('x.txt');
|
||||||
while(f.hasNextLine()) {
|
while(f.hasNextLine()) {
|
||||||
util.puts(x.getNextLine());
|
util.puts(x.getNextLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: You will need to close that above line reader at some point, otherwise
|
||||||
|
// you will run into a "too many open files" error. f.close() or fs.closeSync(f.fd) are
|
||||||
|
// your friends, as only you know when it is safe to close.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Asynchronous operations
|
### Asynchronous operations
|
||||||
|
|
@ -54,7 +58,6 @@ var files = [];
|
||||||
wrench.readdirRecursive('my_directory_name', function(error, curFiles) {
|
wrench.readdirRecursive('my_directory_name', function(error, curFiles) {
|
||||||
// curFiles is what you want
|
// curFiles is what you want
|
||||||
});
|
});
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Questions, comments? Hit me up. (ryan [at] venodesigns.net | http://twitter.com/ryanmcgrath)
|
Questions, comments? Hit me up. (ryan [at] venodesigns.net | http://twitter.com/ryanmcgrath)
|
||||||
|
|
|
||||||
Reference in a new issue