1 /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
18 var fs = require('fs');
19 var assert = require('assert');
22 var srcFilePath = "../resources/test1.txt";
23 var dstFilePath = "../tmp/test_fs1.txt";
26 var fd1 = fs.openSync(srcFilePath, 'r');
27 var buffer = new Buffer(128);
28 var bytes1 = fs.readSync(fd1, buffer, 0, buffer.length, 0);
31 var fd2 = fs.openSync(dstFilePath, 'w');
32 var bytes2 = fs.writeSync(fd2, buffer, 0, bytes1, 0);
35 assert.equal(bytes1, bytes2);
37 var fd3 = fs.openSync(srcFilePath, 'r');
38 var bytes3 = fs.readSync(fd3, buffer, 0, buffer.length, 0);
41 assert.equal(bytes1, bytes3);
43 var result = 'TEST File Read & Write\n';
45 assert.equal(buffer.toString(), result);