git ssb

0+

cel-desktop / ssb-pkg



Tree: 65191f9a9664f013ebe726bb95a1a54b086e1bd5

Files: 65191f9a9664f013ebe726bb95a1a54b086e1bd5 / 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
6var fs = require('fs');
7var path = require('path');
8var theFile = path.join(__dirname, 'test-z-asset.css');
9
10test01();
11
12function 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
32function 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