| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d5e5c75 commit 717db1d
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,21 +29,29 @@ const path = require('path'); | |||
| 29 | 29 | const tmpdir = require('../common/tmpdir'); | |
| 30 | 30 | tmpdir.refresh(); | |
| 31 | 31 | ||
| 32 | - const filepath = path.join(tmpdir.path, 'large.txt'); | ||
| 33 | - const fd = fs.openSync(filepath, 'w+'); | ||
| 34 | - const offset = 5 * 1024 * 1024 * 1024; // 5GB | ||
| 35 | - const message = 'Large File'; | ||
| 32 | + try { | ||
| 36 | 33 | ||
| 37 | - fs.ftruncateSync(fd, offset); | ||
| 38 | - assert.strictEqual(fs.statSync(filepath).size, offset); | ||
| 39 | - const writeBuf = Buffer.from(message); | ||
| 40 | - fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset); | ||
| 41 | - const readBuf = Buffer.allocUnsafe(writeBuf.length); | ||
| 42 | - fs.readSync(fd, readBuf, 0, readBuf.length, offset); | ||
| 43 | - assert.strictEqual(readBuf.toString(), message); | ||
| 44 | - fs.readSync(fd, readBuf, 0, 1, 0); | ||
| 45 | - assert.strictEqual(readBuf[0], 0); | ||
| 34 | + const filepath = path.join(tmpdir.path, 'large.txt'); | ||
| 35 | + const fd = fs.openSync(filepath, 'w+'); | ||
| 36 | + const offset = 5 * 1024 * 1024 * 1024; // 5GB | ||
| 37 | + const message = 'Large File'; | ||
| 46 | 38 | ||
| 47 | - // Verify that floating point positions do not throw. | ||
| 48 | - fs.writeSync(fd, writeBuf, 0, writeBuf.length, 42.000001); | ||
| 49 | - fs.close(fd, common.mustCall()); | ||
| 39 | + fs.ftruncateSync(fd, offset); | ||
| 40 | + assert.strictEqual(fs.statSync(filepath).size, offset); | ||
| 41 | + const writeBuf = Buffer.from(message); | ||
| 42 | + fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset); | ||
| 43 | + const readBuf = Buffer.allocUnsafe(writeBuf.length); | ||
| 44 | + fs.readSync(fd, readBuf, 0, readBuf.length, offset); | ||
| 45 | + assert.strictEqual(readBuf.toString(), message); | ||
| 46 | + fs.readSync(fd, readBuf, 0, 1, 0); | ||
| 47 | + assert.strictEqual(readBuf[0], 0); | ||
| 48 | + | ||
| 49 | + // Verify that floating point positions do not throw. | ||
| 50 | + fs.writeSync(fd, writeBuf, 0, writeBuf.length, 42.000001); | ||
| 51 | + fs.close(fd, common.mustCall()); | ||
| 52 | + } catch (e) { | ||
| 53 | + if (e.code !== 'ENOSPC') { | ||
| 54 | + throw e; | ||
| 55 | + } | ||
| 56 | + common.skip('insufficient disk space'); | ||
| 57 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments