| 97 | } |
| 98 | |
| 99 | function 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 |