-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest1.js
More file actions
57 lines (32 loc) · 1011 Bytes
/
test1.js
File metadata and controls
57 lines (32 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var fs = require('fs');
fs.open('./fuck_u_ido.txt', 'r', function opened(err, fd) {
if (err) { throw err; }
var readBuffer = new Buffer(8),
bufferOffset = 0,
bufferLength = readBuffer.length, filePosition = null,
write_buff = []
;
var fn_read = function()
{
fs.read( fd, readBuffer,
bufferOffset,
bufferLength,
filePosition,
function read( err, readBytes ) {
if ( err ) { throw err; }
//console.log('just read ' + readBytes + ' bytes');
if (readBytes > 0) {
//console.log(readBuffer.slice(0, readBytes));
console.log(readBuffer.toString());
//write_buff = write_buff.concat(readBuffer);
fn_read();
}
else{
console.log( 'closing fd' );
fs.closeSync(fd);
}
}
);
};
fn_read();
});