Files: ca90b5ca0579ebdcc0635288bce4978e3fb200f5 / test / test-50-fs-runtime-layer-3 / test-x-index.js
1259 bytesRaw
1 | /* eslint-disable no-buffer-constructor */ |
2 | /* eslint-disable max-statements-per-line */ |
3 | |
4 | 'use strict'; |
5 | |
6 | var fs = require('fs'); |
7 | var path = require('path'); |
8 | var theFile = path.join(__dirname, 'test-z-asset.css'); |
9 | |
10 | test01(); |
11 | |
12 | function test01 () { |
13 | fs.open(theFile, 'w+', function (error, fd) { |
14 | console.log(error === null); |
15 | var buffer = new Buffer('FOO'); |
16 | fs.write(fd, buffer, 0, buffer.length, null, function (error2) { |
17 | console.log(error2 === null); |
18 | if (error2) console.log(error2.message); |
19 | fs.close(fd, function (error3) { |
20 | console.log(error3 === null); |
21 | console.log('closed'); |
22 | fs.writeFile(theFile, 'BAR BAZ', function (error4) { |
23 | console.log(error4 === null); |
24 | if (error4) console.log(error4.message); |
25 | test02(); |
26 | }); |
27 | }); |
28 | }); |
29 | }); |
30 | } |
31 | |
32 | function test02 () { |
33 | var fd = fs.openSync(theFile, 'w+'); |
34 | var buffer = new Buffer('QUX BARABAZ'); |
35 | var bytesWritten; |
36 | try { bytesWritten = fs.writeSync(fd, buffer, 0, buffer.length); } catch (error) { console.log(error.message); } |
37 | console.log(bytesWritten); |
38 | fs.closeSync(fd); |
39 | try { bytesWritten = fs.writeFileSync(theFile, 'GARAQUX'); } catch (error) { console.log(error.message); } |
40 | console.log(bytesWritten); |
41 | } |
42 |
Built with git-ssb-web