Debian Codegraph @

util/build/node/fs.js

raw symbols SCIP
1 define(["../fileHandleThrottle"], function(fht){
2 var fs = require.nodeRequire("fs");
3 return {
4 statSync:fs.statSync,
5 mkdirSync:fs.mkdirSync,
6 readFileSync:fs.readFileSync,
7 writeFileSync:fs.writeFileSync,
8 readdirSync:fs.readdirSync,
9
10 copyFile:function(src, dest, cb){
11 // Use no encoding, as the file may be text or binary.
12 fht.enqueue(function() {
13 fs.readFile(src, undefined, function (err, contents) {
14 if (err) {
15 fht.release();
16 cb(err);
17 } else {
18 fs.writeFile(dest, contents, undefined, cb);
19 fht.release();
20 }
21 });
22 });
23 },
24
25 readFile:function(filename, encoding, cb){
26 fht.enqueue(function(){
27 fs.readFile(filename, encoding, function(code){
28 fht.release();
29 cb.apply(null, arguments);
30 });
31 });
32 },
33
34 writeFile:function(filename, contents, encoding, cb){
35 fht.enqueue(function(){
36 fs.writeFile(filename, contents, encoding, function(code){
37 fht.release();
38 cb.apply(null, arguments);
39 });
40 });
41 }
42 };
43 });