frida-fs 5.0.1 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +27 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -102,8 +102,7 @@ class ReadStream extends stream.Readable {
|
|
|
102
102
|
const fd = getApi().open(pathStr, constants.O_RDONLY, 0);
|
|
103
103
|
if (fd.value === -1) {
|
|
104
104
|
process.nextTick(() => {
|
|
105
|
-
this.
|
|
106
|
-
this.push(null);
|
|
105
|
+
this.destroy(new Error(getErrorString(fd.errno)));
|
|
107
106
|
});
|
|
108
107
|
return;
|
|
109
108
|
}
|
|
@@ -111,6 +110,15 @@ class ReadStream extends stream.Readable {
|
|
|
111
110
|
this._input = new UnixInputStream(fd.value, { autoClose: true });
|
|
112
111
|
}
|
|
113
112
|
|
|
113
|
+
_destroy(err, callback) {
|
|
114
|
+
if (this._input !== null) {
|
|
115
|
+
this._input.close();
|
|
116
|
+
this._input = null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
callback(err);
|
|
120
|
+
}
|
|
121
|
+
|
|
114
122
|
_read(size) {
|
|
115
123
|
if (this._readRequest !== null)
|
|
116
124
|
return;
|
|
@@ -120,7 +128,6 @@ class ReadStream extends stream.Readable {
|
|
|
120
128
|
this._readRequest = null;
|
|
121
129
|
|
|
122
130
|
if (buffer.byteLength === 0) {
|
|
123
|
-
this._closeInput();
|
|
124
131
|
this.push(null);
|
|
125
132
|
return;
|
|
126
133
|
}
|
|
@@ -130,18 +137,9 @@ class ReadStream extends stream.Readable {
|
|
|
130
137
|
})
|
|
131
138
|
.catch(error => {
|
|
132
139
|
this._readRequest = null;
|
|
133
|
-
this.
|
|
134
|
-
this.emit('error', error);
|
|
135
|
-
this.push(null);
|
|
140
|
+
this.destroy(error);
|
|
136
141
|
});
|
|
137
142
|
}
|
|
138
|
-
|
|
139
|
-
_closeInput() {
|
|
140
|
-
if (this._input !== null) {
|
|
141
|
-
this._input.close();
|
|
142
|
-
this._input = null;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
143
|
}
|
|
146
144
|
|
|
147
145
|
class WriteStream extends stream.Writable {
|
|
@@ -159,15 +157,21 @@ class WriteStream extends stream.Writable {
|
|
|
159
157
|
const fd = getApi().open(pathStr, flags, mode);
|
|
160
158
|
if (fd.value === -1) {
|
|
161
159
|
process.nextTick(() => {
|
|
162
|
-
this.
|
|
163
|
-
this.push(null);
|
|
160
|
+
this.destroy(new Error(getErrorString(fd.errno)));
|
|
164
161
|
});
|
|
165
162
|
return;
|
|
166
163
|
}
|
|
167
164
|
|
|
168
165
|
this._output = new UnixOutputStream(fd.value, { autoClose: true });
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_destroy(err, callback) {
|
|
169
|
+
if (this._output !== null) {
|
|
170
|
+
this._output.close();
|
|
171
|
+
this._output = null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
callback(err);
|
|
171
175
|
}
|
|
172
176
|
|
|
173
177
|
_write(chunk, encoding, callback) {
|
|
@@ -186,13 +190,6 @@ class WriteStream extends stream.Writable {
|
|
|
186
190
|
callback(error);
|
|
187
191
|
});
|
|
188
192
|
}
|
|
189
|
-
|
|
190
|
-
_closeOutput() {
|
|
191
|
-
if (this._output !== null) {
|
|
192
|
-
this._output.close();
|
|
193
|
-
this._output = null;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
193
|
}
|
|
197
194
|
|
|
198
195
|
const direntSpecs = {
|
|
@@ -245,7 +242,7 @@ function enumerateDirectoryEntries(path, callback) {
|
|
|
245
242
|
const dir = opendirImpl(Memory.allocUtf8String(path));
|
|
246
243
|
const dirHandle = dir.value;
|
|
247
244
|
if (dirHandle.isNull())
|
|
248
|
-
throw new Error(
|
|
245
|
+
throw new Error(getErrorString(dir.errno));
|
|
249
246
|
|
|
250
247
|
try {
|
|
251
248
|
let entry;
|
|
@@ -280,7 +277,7 @@ function readFileSync(path, options = {}) {
|
|
|
280
277
|
const openResult = open(pathStr, constants.O_RDONLY, 0);
|
|
281
278
|
const fd = openResult.value;
|
|
282
279
|
if (fd === -1)
|
|
283
|
-
throw new Error(
|
|
280
|
+
throw new Error(getErrorString(openResult.errno));
|
|
284
281
|
|
|
285
282
|
try {
|
|
286
283
|
const fileSize = lseek(fd, 0, SEEK_END).valueOf();
|
|
@@ -296,7 +293,7 @@ function readFileSync(path, options = {}) {
|
|
|
296
293
|
} while (readFailed && readResult.errno === EINTR);
|
|
297
294
|
|
|
298
295
|
if (readFailed)
|
|
299
|
-
throw new Error(
|
|
296
|
+
throw new Error(getErrorString(readResult.errno));
|
|
300
297
|
|
|
301
298
|
if (n !== fileSize.valueOf())
|
|
302
299
|
throw new Error('Short read');
|
|
@@ -327,7 +324,7 @@ function readlinkSync(path) {
|
|
|
327
324
|
const result = api.readlink(pathStr, buf, linkSize);
|
|
328
325
|
const n = result.value.valueOf();
|
|
329
326
|
if (n === -1)
|
|
330
|
-
throw new Error(
|
|
327
|
+
throw new Error(getErrorString(result.errno));
|
|
331
328
|
|
|
332
329
|
return buf.readUtf8String(n);
|
|
333
330
|
}
|
|
@@ -339,7 +336,7 @@ function unlinkSync(path) {
|
|
|
339
336
|
|
|
340
337
|
const result = unlink(pathStr);
|
|
341
338
|
if (result.value === -1)
|
|
342
|
-
throw new Error(
|
|
339
|
+
throw new Error(getErrorString(result.errno));
|
|
343
340
|
}
|
|
344
341
|
|
|
345
342
|
const statFields = new Set([
|
|
@@ -526,7 +523,7 @@ function performStat(impl, path) {
|
|
|
526
523
|
const buf = Memory.alloc(statBufSize);
|
|
527
524
|
const result = impl(Memory.allocUtf8String(path), buf);
|
|
528
525
|
if (result.value !== 0)
|
|
529
|
-
throw new Error(
|
|
526
|
+
throw new Error(getErrorString(result.errno));
|
|
530
527
|
|
|
531
528
|
return new Proxy(new Stats(), {
|
|
532
529
|
has(target, property) {
|