Created
September 14, 2010 03:10
-
-
Save brapse/578466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Crawl.prototype.start_local = function(directory) { | |
| var that = this; | |
| sys.debug('starting local: ' + directory); | |
| fs.readdir(directory, function(err, files) { | |
| if(err) throw err; | |
| files.forEach(function(file) { | |
| sys.debug('file: ' + file); | |
| var filename = directory + '/' + file; | |
| fs.open(filename, 'r', function(err, fd) { | |
| if(err) throw err; | |
| fs.stat(filename, function(err, stats) { | |
| sys.debug('stats:' + sys.inspect(stats)); | |
| if(err) throw err; | |
| fs.read(fd, stats.size, null, 'utf8', function(err, contents) { | |
| sys.debug('contents:' + contents); | |
| if(err) throw err; | |
| that.emit('page', file, contents); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment