1 | var constants = process.binding('constants');
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | var FileDescriptor = exports.FileDescriptor = function(flags) {
|
11 |
|
12 | |
13 |
|
14 |
|
15 |
|
16 | this._flags = flags;
|
17 |
|
18 | |
19 |
|
20 |
|
21 |
|
22 | this._item = null;
|
23 |
|
24 | |
25 |
|
26 |
|
27 |
|
28 | this._position = 0;
|
29 |
|
30 | };
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | FileDescriptor.prototype.setItem = function(item) {
|
38 | this._item = item;
|
39 | };
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | FileDescriptor.prototype.getItem = function() {
|
47 | return this._item;
|
48 | };
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | FileDescriptor.prototype.getPosition = function() {
|
56 | return this._position;
|
57 | };
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | FileDescriptor.prototype.setPosition = function(position) {
|
65 | this._position = position;
|
66 | };
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | FileDescriptor.prototype.isAppend = function() {
|
74 | return ((this._flags & constants.O_APPEND) === constants.O_APPEND);
|
75 | };
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | FileDescriptor.prototype.isCreate = function() {
|
83 | return ((this._flags & constants.O_CREAT) === constants.O_CREAT);
|
84 | };
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | FileDescriptor.prototype.isRead = function() {
|
92 |
|
93 | return (this._flags === constants.O_RDONLY) ||
|
94 | (this._flags === (constants.O_RDONLY | constants.O_SYNC)) ||
|
95 | ((this._flags & constants.O_RDWR) === constants.O_RDWR);
|
96 | };
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | FileDescriptor.prototype.isWrite = function() {
|
104 | return ((this._flags & constants.O_WRONLY) === constants.O_WRONLY) ||
|
105 | ((this._flags & constants.O_RDWR) === constants.O_RDWR);
|
106 | };
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | FileDescriptor.prototype.isTruncate = function() {
|
114 | return (this._flags & constants.O_TRUNC) === constants.O_TRUNC;
|
115 | };
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | FileDescriptor.prototype.isExclusive = function() {
|
123 | return ((this._flags & constants.O_EXCL) === constants.O_EXCL);
|
124 | };
|