Created
July 3, 2012 04:07
-
-
Save clonn/3037620 to your computer and use it in GitHub Desktop.
Simple read file system on Node.js, let you know how to prevent checked file tiwce by curr time, prev time. Another is making you know how to get listener from watchFile API
This file contains 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
var fs = require('fs'); | |
var fullpath = '/home/clonn/test.html'; | |
fs.watchFile(fullpath, function (curr, prev) { | |
if (curr.mtime.getTime() !== prev.mtime.getTime()) | |
console.log('file update'); | |
}); |
This file contains 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
var fs = require('fs'); | |
var fullpath = '/home/clonn/test.html'; | |
var listen = fs.watchFile(fullpath, function (curr, prev) {}); | |
listen.on('change', , function (curr, prev) { | |
if (curr.mtime.getTime() !== prev.mtime.getTime()) | |
console.log('file update'); | |
}); |
This file contains 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
var fs = require('fs'); | |
var fullpath = '/home/clonn/test.html'; | |
fs.watchFile(fullpath, function (curr, prev) { | |
console.log('file update') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
checked_file.js
make checking files to prevent display log twice by using current time, previous time.
checked_files_listen.js
Get listener from watchFile API, and let people know to using.
simple_watchfile.js
Simple watchFile API. it is simple, but it does not work well.