bare-fs 1.6.3 → 1.6.5
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/binding.c +12 -12
- package/index.js +8 -8
- package/package.json +1 -1
package/binding.c
CHANGED
|
@@ -490,8 +490,8 @@ bare_fs_read (js_env_t *env, js_callback_info_t *info) {
|
|
|
490
490
|
err = js_get_value_uint32(env, argv[1], &fd);
|
|
491
491
|
assert(err == 0);
|
|
492
492
|
|
|
493
|
-
|
|
494
|
-
err = js_get_typedarray_info(env, argv[2], NULL, &data, NULL, NULL, NULL);
|
|
493
|
+
uint8_t *data;
|
|
494
|
+
err = js_get_typedarray_info(env, argv[2], NULL, (void **) &data, NULL, NULL, NULL);
|
|
495
495
|
assert(err == 0);
|
|
496
496
|
|
|
497
497
|
uint32_t offset;
|
|
@@ -509,7 +509,7 @@ bare_fs_read (js_env_t *env, js_callback_info_t *info) {
|
|
|
509
509
|
uv_loop_t *loop;
|
|
510
510
|
js_get_env_loop(env, &loop);
|
|
511
511
|
|
|
512
|
-
uv_buf_t buf = uv_buf_init(data + offset, len);
|
|
512
|
+
uv_buf_t buf = uv_buf_init((void *) (data + offset), len);
|
|
513
513
|
|
|
514
514
|
uv_fs_read(loop, (uv_fs_t *) req, fd, &buf, 1, pos, on_fs_response);
|
|
515
515
|
|
|
@@ -532,8 +532,8 @@ bare_fs_read_sync (js_env_t *env, js_callback_info_t *info) {
|
|
|
532
532
|
err = js_get_value_uint32(env, argv[0], &fd);
|
|
533
533
|
assert(err == 0);
|
|
534
534
|
|
|
535
|
-
|
|
536
|
-
err = js_get_typedarray_info(env, argv[1], NULL, &data, NULL, NULL, NULL);
|
|
535
|
+
uint8_t *data;
|
|
536
|
+
err = js_get_typedarray_info(env, argv[1], NULL, (void **) &data, NULL, NULL, NULL);
|
|
537
537
|
assert(err == 0);
|
|
538
538
|
|
|
539
539
|
uint32_t offset;
|
|
@@ -551,7 +551,7 @@ bare_fs_read_sync (js_env_t *env, js_callback_info_t *info) {
|
|
|
551
551
|
uv_loop_t *loop;
|
|
552
552
|
js_get_env_loop(env, &loop);
|
|
553
553
|
|
|
554
|
-
uv_buf_t buf = uv_buf_init(data + offset, len);
|
|
554
|
+
uv_buf_t buf = uv_buf_init((void *) (data + offset), len);
|
|
555
555
|
|
|
556
556
|
uv_fs_t req;
|
|
557
557
|
uv_fs_read(loop, (uv_fs_t *) &req, fd, &buf, 1, pos, NULL);
|
|
@@ -640,8 +640,8 @@ bare_fs_write (js_env_t *env, js_callback_info_t *info) {
|
|
|
640
640
|
err = js_get_value_uint32(env, argv[1], &fd);
|
|
641
641
|
assert(err == 0);
|
|
642
642
|
|
|
643
|
-
|
|
644
|
-
err = js_get_typedarray_info(env, argv[2], NULL, &data, NULL, NULL, NULL);
|
|
643
|
+
uint8_t *data;
|
|
644
|
+
err = js_get_typedarray_info(env, argv[2], NULL, (void **) &data, NULL, NULL, NULL);
|
|
645
645
|
assert(err == 0);
|
|
646
646
|
|
|
647
647
|
uint32_t offset;
|
|
@@ -659,7 +659,7 @@ bare_fs_write (js_env_t *env, js_callback_info_t *info) {
|
|
|
659
659
|
uv_loop_t *loop;
|
|
660
660
|
js_get_env_loop(env, &loop);
|
|
661
661
|
|
|
662
|
-
uv_buf_t buf = uv_buf_init(data + offset, len);
|
|
662
|
+
uv_buf_t buf = uv_buf_init((void *) (data + offset), len);
|
|
663
663
|
|
|
664
664
|
uv_fs_write(loop, (uv_fs_t *) req, fd, &buf, 1, pos, on_fs_response);
|
|
665
665
|
|
|
@@ -682,8 +682,8 @@ bare_fs_write_sync (js_env_t *env, js_callback_info_t *info) {
|
|
|
682
682
|
err = js_get_value_uint32(env, argv[0], &fd);
|
|
683
683
|
assert(err == 0);
|
|
684
684
|
|
|
685
|
-
|
|
686
|
-
err = js_get_typedarray_info(env, argv[1], NULL, &data, NULL, NULL, NULL);
|
|
685
|
+
uint8_t *data;
|
|
686
|
+
err = js_get_typedarray_info(env, argv[1], NULL, (void **) &data, NULL, NULL, NULL);
|
|
687
687
|
assert(err == 0);
|
|
688
688
|
|
|
689
689
|
uint32_t offset;
|
|
@@ -701,7 +701,7 @@ bare_fs_write_sync (js_env_t *env, js_callback_info_t *info) {
|
|
|
701
701
|
uv_loop_t *loop;
|
|
702
702
|
js_get_env_loop(env, &loop);
|
|
703
703
|
|
|
704
|
-
uv_buf_t buf = uv_buf_init(data + offset, len);
|
|
704
|
+
uv_buf_t buf = uv_buf_init((void *) (data + offset), len);
|
|
705
705
|
|
|
706
706
|
uv_fs_t req;
|
|
707
707
|
uv_fs_write(loop, &req, fd, &buf, 1, pos, NULL);
|
package/index.js
CHANGED
|
@@ -203,7 +203,7 @@ function read (fd, buffer, offset, len, pos, cb) {
|
|
|
203
203
|
throw typeError('ERR_OUT_OF_RANGE', 'File descriptor is out of range. It must be >= 0 && <= 2147483647. Received ' + fd)
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
206
|
+
if (!Buffer.isBuffer(buffer) && !ArrayBuffer.isView(buffer)) {
|
|
207
207
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Buffer must be a buffer. Received type ' + (typeof buffer) + ' (' + buffer + ')')
|
|
208
208
|
}
|
|
209
209
|
|
|
@@ -241,7 +241,7 @@ function readSync (fd, buffer, offset = 0, len = buffer.byteLength - offset, pos
|
|
|
241
241
|
throw typeError('ERR_OUT_OF_RANGE', 'File descriptor is out of range. It must be >= 0 && <= 2147483647. Received ' + fd)
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
244
|
+
if (!Buffer.isBuffer(buffer) && !ArrayBuffer.isView(buffer)) {
|
|
245
245
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Buffer must be a buffer. Received type ' + (typeof buffer) + ' (' + buffer + ')')
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -280,7 +280,7 @@ function write (fd, buffer, offset, len, pos, cb) {
|
|
|
280
280
|
throw typeError('ERR_OUT_OF_RANGE', 'File descriptor is out of range. It must be >= 0 && <= 2147483647. Received ' + fd)
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
283
|
+
if (!Buffer.isBuffer(buffer) && !ArrayBuffer.isView(buffer)) {
|
|
284
284
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Buffer must be a buffer. Received type ' + (typeof buffer) + ' (' + buffer + ')')
|
|
285
285
|
}
|
|
286
286
|
|
|
@@ -318,7 +318,7 @@ function writeSync (fd, buffer, offset = 0, len = buffer.byteLength - offset, po
|
|
|
318
318
|
throw typeError('ERR_OUT_OF_RANGE', 'File descriptor is out of range. It must be >= 0 && <= 2147483647. Received ' + fd)
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
321
|
+
if (!Buffer.isBuffer(buffer) && !ArrayBuffer.isView(buffer)) {
|
|
322
322
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Buffer must be a buffer. Received type ' + (typeof buffer) + ' (' + buffer + ')')
|
|
323
323
|
}
|
|
324
324
|
|
|
@@ -743,7 +743,7 @@ function writeFile (path, data, opts, cb) {
|
|
|
743
743
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')')
|
|
744
744
|
}
|
|
745
745
|
|
|
746
|
-
if (typeof data !== 'string' && !Buffer.isBuffer(data)) {
|
|
746
|
+
if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
|
|
747
747
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
|
|
748
748
|
}
|
|
749
749
|
|
|
@@ -759,12 +759,12 @@ function writeFile (path, data, opts, cb) {
|
|
|
759
759
|
|
|
760
760
|
if (typeof data === 'string') data = Buffer.from(data, opts.encoding)
|
|
761
761
|
|
|
762
|
-
open(path, opts.flag || 'w', opts.mode, function (err, fd) {
|
|
762
|
+
open(path, opts.flag || 'w', opts || 0o666.mode, function (err, fd) {
|
|
763
763
|
if (err) return cb(err)
|
|
764
764
|
|
|
765
765
|
write(fd, data, loop)
|
|
766
766
|
|
|
767
|
-
function loop (err, w
|
|
767
|
+
function loop (err, w) {
|
|
768
768
|
if (err) return closeAndError(err)
|
|
769
769
|
if (w === data.byteLength) return done()
|
|
770
770
|
write(fd, data.subarray(w), loop)
|
|
@@ -790,7 +790,7 @@ function writeFileSync (path, data, opts) {
|
|
|
790
790
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')')
|
|
791
791
|
}
|
|
792
792
|
|
|
793
|
-
if (typeof data !== 'string' && !Buffer.isBuffer(data)) {
|
|
793
|
+
if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
|
|
794
794
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
|
|
795
795
|
}
|
|
796
796
|
|