You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.
Or if you have a file with a single line that is not terminated with a \n, then lineReader will behave as if the file is empty.
The following code generates hash values for all files in a file directory. If there are two single line files, their hash will be the same value and this value will also be the same as a file that is totally empty.
Or if you have a file with a single line that is not terminated with a \n, then lineReader will behave as if the file is empty.
The following code generates hash values for all files in a file directory. If there are two single line files, their hash will be the same value and this value will also be the same as a file that is totally empty.
allFiles = wrench.readdirSyncRecursive('.');
allFiles.sort();
allFiles = allFiles.filter(function (element) {
return (element.indexOf('.git') === -1 && element.indexOf('.log') === -1);
});
if (allFiles.indexOf('review') === -1) {
// create the review directory
wrench.mkdirSyncRecursive('review', '0700');
} else {
// don't want to create hashes for ourselves or git files
allFiles.splice(allFiles.indexOf('review'), 1);
allFiles.splice(allFiles.indexOf('review/hashes.txt'), 1);
}
ws = fs.createWriteStream('review/hashes.txt', { flags: 'w', encoding: null, mode: '0600' });
ws.on('open', function (fd) {
var i,
ilen,
name,
stats,
f,
content,
hash,
buffer;
for (i = 0, ilen = allFiles.length; i < ilen; i += 1) {
name = allFiles[i];
stats = fs.statSync(name);
console.log('processing file [' + name + ']');
if (stats.isFile()) {
f = new wrench.LineReader(name);
content = '';
while (f.hasNextLine()) {
content += f.getNextLine();
}
fs.closeSync( f.fd);
hash = crypto
.createHash('md5')
.update(content)
.digest('hex');
buffer = name + '\n' + hash + '\n\n';
console.log(buffer);
ws.write(buffer);
}
}
ws.end();
});
The text was updated successfully, but these errors were encountered: