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