added node example
This commit is contained in:
parent
527d76dbd9
commit
50fe98e94d
|
@ -0,0 +1,20 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var fs = require('fs')
|
||||||
|
, path = require('path')
|
||||||
|
, dirpath = path.join(__dirname, 'testfiles')
|
||||||
|
;
|
||||||
|
|
||||||
|
fs.readdir(dirpath, function (err, nodes) {
|
||||||
|
nodes.forEach(function (node) {
|
||||||
|
var filepath = path.join(dirpath, node)
|
||||||
|
;
|
||||||
|
|
||||||
|
console.log(filepath);
|
||||||
|
fs.readFile(filepath, null, function (err, contents) {
|
||||||
|
console.log(node, contents.length);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('All Done');
|
||||||
|
});
|
|
@ -0,0 +1,22 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var fs = require('fs')
|
||||||
|
, forEachAsync = require('foreachasync').forEachAsync
|
||||||
|
, path = require('path')
|
||||||
|
, dirpath = path.join(__dirname, 'testfiles')
|
||||||
|
;
|
||||||
|
|
||||||
|
fs.readdir(dirpath, function (err, nodes) {
|
||||||
|
forEachAsync(nodes, function (next, node) {
|
||||||
|
var filepath = path.join(dirpath, node)
|
||||||
|
;
|
||||||
|
|
||||||
|
console.log(filepath);
|
||||||
|
fs.readFile(filepath, null, function (err, contents) {
|
||||||
|
console.log(node, contents.length);
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
}).then(function () {
|
||||||
|
console.log('All Done!');
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,8 @@
|
||||||
|
mkdir -p testfiles
|
||||||
|
touch ./testfiles/0b.bin
|
||||||
|
dd bs=1m count=1 if=/dev/zero of=./testfiles/1mb.bin
|
||||||
|
dd bs=1k count=64 if=/dev/zero of=./testfiles/64kb.bin
|
||||||
|
dd bs=1k count=96 if=/dev/zero of=./testfiles/96kb.bin
|
||||||
|
dd bs=1k count=1 if=/dev/zero of=./testfiles/1kb.bin
|
||||||
|
# this will copy one block which could be between 512b and 4k (or more)
|
||||||
|
dd bs=1b count=1 if=/dev/zero of=./testfiles/block.bin
|
Loading…
Reference in New Issue