a79fa0198878e0cd3ade9b86cd0d73b2c44fdba3.svn-base
2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
 * Temporary - The lord of tmp.
 *
 * Author: Veselin Todorov <hi@vesln.com>
 * Licensed under the MIT License.
 */
/**
 * Dependencies.
 */
var fs = require('fs');
var path = require('path');
var generator = require('./generator');
var detector = require('./detector');
var Base = require('./base');
/**
 * File constructor.
 *
 * @param {String|null} name
 */
function File(name) {
  this.init(name);
};
/**
 * File extends from tmp.
 */
File.prototype.__proto__ = Base.prototype;
/**
 * Creates new file.
 *
 * @param {String} filename
 */
File.prototype.create = function(filename) {
  return fs.writeFileSync(path.normalize(filename), '');
};
/**
 * Asynchronously reads the entire contents of a file.
 */
File.prototype.readFile = function() {
  fs.readFile.apply(fs, this.prepareArgs(arguments));
};
/**
 * Synchronous read.
 */
File.prototype.readFileSync = function() {
  return fs.readFileSync.apply(fs, this.prepareArgs(arguments));
};
/**
 * Asynchronously writes data to a file.
 */
File.prototype.writeFile = function() {
  fs.writeFile.apply(fs, this.prepareArgs(arguments));
};
/**
 * Synchronous writes data to a file.
 */
File.prototype.writeFileSync = function() {
  return fs.writeFileSync.apply(fs, this.prepareArgs(arguments));
};
/**
 * Asynchronous file open.
 */
File.prototype.open = function() {
  fs.open.apply(fs, this.prepareArgs(arguments));
};
/**
 * Synchronous open.
 */
File.prototype.openSync = function() {
  return fs.openSync.apply(fs, this.prepareArgs(arguments));
};
/**
 * Asynchronous close.
 */
File.prototype.close = function() {
  fs.close.apply(fs, Array.prototype.slice.call(arguments));
};
/**
 * Synchronous close.
 */
File.prototype.closeSync = function() {
  return fs.closeSync.apply(fs, Array.prototype.slice.call(arguments));
};
/**
 * Asynchronous unlink.
 */
File.prototype.unlink = function() {
  fs.unlink.apply(fs, this.prepareArgs(arguments));
};
/**
 * Synchronous unlink.
 */
File.prototype.unlinkSync = function() {
  return fs.unlinkSync.apply(fs, this.prepareArgs(arguments));
};
/**
 * Exporting the lib.
 */
module.exports = File;