MCPcopy Index your code
hub / github.com/nodejs/node / testFtruncate

Function testFtruncate

test/parallel/test-fs-truncate.js:99–127  ·  view source on GitHub ↗
(cb)

Source from the content-addressed store, hash-verified

97}
98
99function testFtruncate(cb) {
100 fs.writeFile(filename, data, function(er) {
101 if (er) return cb(er);
102 fs.stat(filename, function(er, stat) {
103 if (er) return cb(er);
104 assert.strictEqual(stat.size, 1024 * 16);
105
106 fs.open(filename, 'w', function(er, fd) {
107 if (er) return cb(er);
108 fs.ftruncate(fd, 1024, function(er) {
109 if (er) return cb(er);
110 fs.stat(filename, function(er, stat) {
111 if (er) return cb(er);
112 assert.strictEqual(stat.size, 1024);
113
114 fs.ftruncate(fd, function(er) {
115 if (er) return cb(er);
116 fs.stat(filename, function(er, stat) {
117 if (er) return cb(er);
118 assert.strictEqual(stat.size, 0);
119 fs.close(fd, cb);
120 });
121 });
122 });
123 });
124 });
125 });
126 });
127}
128/* eslint-enable node-core/must-call-assert */
129
130// Make sure if the size of the file is smaller than the length then it is

Callers 1

Calls 6

ftruncateMethod · 0.80
cbFunction · 0.70
openMethod · 0.65
closeMethod · 0.65
writeFileMethod · 0.45
statMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…