@gjsify/fs 0.0.2 → 0.0.3
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/lib/cjs/callback.js +30 -49
- package/lib/cjs/dirent.js +15 -44
- package/lib/cjs/encoding.js +7 -26
- package/lib/cjs/file-handle.js +44 -73
- package/lib/cjs/fs-watcher.js +16 -45
- package/lib/cjs/index.js +92 -92
- package/lib/cjs/promises.js +54 -83
- package/lib/cjs/read-stream.js +17 -46
- package/lib/cjs/stats.js +9 -38
- package/lib/cjs/sync.js +50 -79
- package/lib/cjs/types/encoding-option.js +0 -15
- package/lib/cjs/types/file-read-options.js +0 -15
- package/lib/cjs/types/file-read-result.js +0 -15
- package/lib/cjs/types/flag-and-open-mode.js +0 -15
- package/lib/cjs/types/index.js +6 -22
- package/lib/cjs/types/open-flags.js +0 -15
- package/lib/cjs/types/read-options.js +0 -15
- package/lib/cjs/utils.js +6 -25
- package/lib/cjs/write-stream.js +14 -33
- package/package.json +9 -9
package/lib/cjs/index.js
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
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
|
-
existsSync: () => import_sync.existsSync,
|
|
36
|
-
lstat: () => import_callback.lstat,
|
|
37
|
-
lstatSync: () => import_sync.lstatSync,
|
|
38
|
-
mkdirSync: () => import_sync.mkdirSync,
|
|
39
|
-
mkdtempSync: () => import_sync.mkdtempSync,
|
|
40
|
-
open: () => import_callback.open,
|
|
41
|
-
openSync: () => import_sync.openSync,
|
|
42
|
-
promises: () => promises,
|
|
43
|
-
read: () => import_callback.read,
|
|
44
|
-
readFileSync: () => import_sync.readFileSync,
|
|
45
|
-
readdir: () => import_callback.readdir,
|
|
46
|
-
readdirSync: () => import_sync.readdirSync,
|
|
47
|
-
realpath: () => import_callback.realpath,
|
|
48
|
-
realpathSync: () => import_sync.realpathSync,
|
|
49
|
-
rm: () => import_callback.rm,
|
|
50
|
-
rmSync: () => import_sync.rmSync,
|
|
51
|
-
rmdirSync: () => import_sync.rmdirSync,
|
|
52
|
-
statSync: () => import_sync.statSync,
|
|
53
|
-
symlink: () => import_callback.symlink,
|
|
54
|
-
symlinkSync: () => import_sync.symlinkSync,
|
|
55
|
-
unlinkSync: () => import_sync.unlinkSync,
|
|
56
|
-
watch: () => import_sync.watch,
|
|
57
|
-
write: () => import_callback.write,
|
|
58
|
-
writeFileSync: () => import_sync.writeFileSync
|
|
59
|
-
});
|
|
60
|
-
module.exports = __toCommonJS(src_exports);
|
|
61
|
-
var import_sync = require("./sync.js");
|
|
62
|
-
var import_callback = require("./callback.js");
|
|
63
|
-
var import_fs_watcher = __toESM(require("./fs-watcher.js"), 1);
|
|
64
|
-
var import_read_stream = require("./read-stream.js");
|
|
65
|
-
var promises = __toESM(require("./promises.js"), 1);
|
|
1
|
+
import {
|
|
2
|
+
existsSync,
|
|
3
|
+
readdirSync,
|
|
4
|
+
readFileSync,
|
|
5
|
+
writeFileSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
rmdirSync,
|
|
8
|
+
unlinkSync,
|
|
9
|
+
watch,
|
|
10
|
+
mkdtempSync,
|
|
11
|
+
rmSync,
|
|
12
|
+
statSync,
|
|
13
|
+
openSync,
|
|
14
|
+
realpathSync,
|
|
15
|
+
symlinkSync,
|
|
16
|
+
lstatSync
|
|
17
|
+
} from "./sync.js";
|
|
18
|
+
import {
|
|
19
|
+
open,
|
|
20
|
+
close,
|
|
21
|
+
read,
|
|
22
|
+
write,
|
|
23
|
+
rm,
|
|
24
|
+
realpath,
|
|
25
|
+
readdir,
|
|
26
|
+
symlink,
|
|
27
|
+
lstat
|
|
28
|
+
} from "./callback.js";
|
|
29
|
+
import FSWatcher from "./fs-watcher.js";
|
|
30
|
+
import {
|
|
31
|
+
createReadStream,
|
|
32
|
+
ReadStream
|
|
33
|
+
} from "./read-stream.js";
|
|
34
|
+
import * as promises from "./promises.js";
|
|
66
35
|
var src_default = {
|
|
67
|
-
FSWatcher
|
|
68
|
-
existsSync
|
|
69
|
-
readdirSync
|
|
70
|
-
readFileSync
|
|
71
|
-
writeFileSync
|
|
72
|
-
mkdirSync
|
|
73
|
-
rmdirSync
|
|
74
|
-
unlinkSync
|
|
75
|
-
mkdtempSync
|
|
76
|
-
rmSync
|
|
77
|
-
statSync
|
|
78
|
-
openSync
|
|
79
|
-
realpathSync
|
|
80
|
-
symlinkSync
|
|
81
|
-
lstatSync
|
|
82
|
-
watch
|
|
83
|
-
createReadStream
|
|
84
|
-
ReadStream
|
|
36
|
+
FSWatcher,
|
|
37
|
+
existsSync,
|
|
38
|
+
readdirSync,
|
|
39
|
+
readFileSync,
|
|
40
|
+
writeFileSync,
|
|
41
|
+
mkdirSync,
|
|
42
|
+
rmdirSync,
|
|
43
|
+
unlinkSync,
|
|
44
|
+
mkdtempSync,
|
|
45
|
+
rmSync,
|
|
46
|
+
statSync,
|
|
47
|
+
openSync,
|
|
48
|
+
realpathSync,
|
|
49
|
+
symlinkSync,
|
|
50
|
+
lstatSync,
|
|
51
|
+
watch,
|
|
52
|
+
createReadStream,
|
|
53
|
+
ReadStream,
|
|
54
|
+
promises,
|
|
55
|
+
open,
|
|
56
|
+
close,
|
|
57
|
+
read,
|
|
58
|
+
write,
|
|
59
|
+
rm,
|
|
60
|
+
realpath,
|
|
61
|
+
readdir,
|
|
62
|
+
symlink,
|
|
63
|
+
lstat
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
FSWatcher,
|
|
67
|
+
ReadStream,
|
|
68
|
+
close,
|
|
69
|
+
createReadStream,
|
|
70
|
+
src_default as default,
|
|
71
|
+
existsSync,
|
|
72
|
+
lstat,
|
|
73
|
+
lstatSync,
|
|
74
|
+
mkdirSync,
|
|
75
|
+
mkdtempSync,
|
|
76
|
+
open,
|
|
77
|
+
openSync,
|
|
85
78
|
promises,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
79
|
+
read,
|
|
80
|
+
readFileSync,
|
|
81
|
+
readdir,
|
|
82
|
+
readdirSync,
|
|
83
|
+
realpath,
|
|
84
|
+
realpathSync,
|
|
85
|
+
rm,
|
|
86
|
+
rmSync,
|
|
87
|
+
rmdirSync,
|
|
88
|
+
statSync,
|
|
89
|
+
symlink,
|
|
90
|
+
symlinkSync,
|
|
91
|
+
unlinkSync,
|
|
92
|
+
watch,
|
|
93
|
+
write,
|
|
94
|
+
writeFileSync
|
|
95
95
|
};
|
package/lib/cjs/promises.js
CHANGED
|
@@ -1,63 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var promises_exports = {};
|
|
29
|
-
__export(promises_exports, {
|
|
30
|
-
default: () => promises_default,
|
|
31
|
-
lstat: () => import_fs_lstat.lstatPromise,
|
|
32
|
-
mkdir: () => mkdir,
|
|
33
|
-
mkdtemp: () => mkdtemp,
|
|
34
|
-
open: () => open,
|
|
35
|
-
readFile: () => readFile,
|
|
36
|
-
readdir: () => import_fs_readdir.readdirPromise,
|
|
37
|
-
realpath: () => import_fs_realpath.realpathPromise,
|
|
38
|
-
rm: () => rm,
|
|
39
|
-
rmdir: () => rmdir,
|
|
40
|
-
stat: () => import_fs_stat.statPromise,
|
|
41
|
-
symlink: () => import_fs_symlink.symlinkPromise,
|
|
42
|
-
unlink: () => unlink,
|
|
43
|
-
write: () => write,
|
|
44
|
-
writeFile: () => writeFile
|
|
45
|
-
});
|
|
46
|
-
module.exports = __toCommonJS(promises_exports);
|
|
47
|
-
var import_gio_2 = __toESM(require("@girs/gio-2.0"), 1);
|
|
48
|
-
var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
|
|
49
|
-
var import_utils = require("@gjsify/utils");
|
|
50
|
-
var import_path = require("path");
|
|
51
|
-
var import_encoding = require("./encoding.js");
|
|
52
|
-
var import_sync = require("./sync.js");
|
|
53
|
-
var import_file_handle = require("./file-handle.js");
|
|
54
|
-
var import_utils2 = require("./utils.js");
|
|
55
|
-
var import_dirent = require("./dirent.js");
|
|
56
|
-
var import_fs_realpath = require("@gjsify/deno_std/node/_fs/_fs_realpath");
|
|
57
|
-
var import_fs_readdir = require("@gjsify/deno_std/node/_fs/_fs_readdir");
|
|
58
|
-
var import_fs_symlink = require("@gjsify/deno_std/node/_fs/_fs_symlink");
|
|
59
|
-
var import_fs_lstat = require("@gjsify/deno_std/node/_fs/_fs_lstat");
|
|
60
|
-
var import_fs_stat = require("@gjsify/deno_std/node/_fs/_fs_stat");
|
|
1
|
+
import Gio from "@girs/gio-2.0";
|
|
2
|
+
import GLib from "@girs/glib-2.0";
|
|
3
|
+
import { warnNotImplemented } from "@gjsify/utils";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
import { getEncodingFromOptions, encodeUint8Array, decode } from "./encoding.js";
|
|
6
|
+
import { writeFileSync, mkdirSync, rmdirSync, unlinkSync } from "./sync.js";
|
|
7
|
+
import { FileHandle } from "./file-handle.js";
|
|
8
|
+
import { tempDirPath } from "./utils.js";
|
|
9
|
+
import { Dirent } from "./dirent.js";
|
|
10
|
+
import { realpathPromise as realpath } from "@gjsify/deno_std/node/_fs/_fs_realpath";
|
|
11
|
+
import { readdirPromise as readdir } from "@gjsify/deno_std/node/_fs/_fs_readdir";
|
|
12
|
+
import { symlinkPromise as symlink } from "@gjsify/deno_std/node/_fs/_fs_symlink";
|
|
13
|
+
import { lstatPromise as lstat } from "@gjsify/deno_std/node/_fs/_fs_lstat";
|
|
14
|
+
import { statPromise as stat } from "@gjsify/deno_std/node/_fs/_fs_stat";
|
|
61
15
|
async function mkdir(path, options) {
|
|
62
16
|
let recursive;
|
|
63
17
|
let mode = 511;
|
|
@@ -69,14 +23,14 @@ async function mkdir(path, options) {
|
|
|
69
23
|
} else {
|
|
70
24
|
mode = options;
|
|
71
25
|
}
|
|
72
|
-
const firstPath =
|
|
26
|
+
const firstPath = mkdirSync(path, {
|
|
73
27
|
recursive,
|
|
74
28
|
mode
|
|
75
29
|
});
|
|
76
30
|
return firstPath;
|
|
77
31
|
}
|
|
78
32
|
async function readFile(path, options = { encoding: null, flag: "r" }) {
|
|
79
|
-
const file =
|
|
33
|
+
const file = Gio.File.new_for_path(path.toString());
|
|
80
34
|
const [ok, data] = await new Promise((resolve, reject) => {
|
|
81
35
|
file.load_contents_async(null, (self, res) => {
|
|
82
36
|
try {
|
|
@@ -89,28 +43,28 @@ async function readFile(path, options = { encoding: null, flag: "r" }) {
|
|
|
89
43
|
if (!ok) {
|
|
90
44
|
throw new Error("failed to read file");
|
|
91
45
|
}
|
|
92
|
-
return
|
|
46
|
+
return encodeUint8Array(getEncodingFromOptions(options, "buffer"), data);
|
|
93
47
|
}
|
|
94
48
|
async function mkdtemp(prefix, options) {
|
|
95
|
-
const encoding =
|
|
96
|
-
const path =
|
|
49
|
+
const encoding = getEncodingFromOptions(options);
|
|
50
|
+
const path = tempDirPath(prefix);
|
|
97
51
|
await mkdir(
|
|
98
52
|
path,
|
|
99
53
|
{ recursive: false, mode: 448 }
|
|
100
54
|
);
|
|
101
|
-
return
|
|
55
|
+
return decode(path, encoding);
|
|
102
56
|
}
|
|
103
57
|
async function writeFile(path, data) {
|
|
104
|
-
return
|
|
58
|
+
return writeFileSync(path, data);
|
|
105
59
|
}
|
|
106
60
|
async function rmdir(path, options) {
|
|
107
|
-
return
|
|
61
|
+
return rmdirSync(path, options);
|
|
108
62
|
}
|
|
109
63
|
async function unlink(path) {
|
|
110
|
-
return
|
|
64
|
+
return unlinkSync(path);
|
|
111
65
|
}
|
|
112
66
|
async function open(path, flags, mode) {
|
|
113
|
-
return new
|
|
67
|
+
return new FileHandle({
|
|
114
68
|
path,
|
|
115
69
|
flags,
|
|
116
70
|
mode
|
|
@@ -123,39 +77,39 @@ async function write(fd, data, positionOrOffset, encodingOrLength, position) {
|
|
|
123
77
|
return _writeBuf(fd, data, positionOrOffset, encodingOrLength, position);
|
|
124
78
|
}
|
|
125
79
|
async function _writeBuf(fd, buffer, offset, length, position) {
|
|
126
|
-
|
|
80
|
+
warnNotImplemented("fs.promises.write");
|
|
127
81
|
return {
|
|
128
82
|
bytesWritten: 0,
|
|
129
83
|
buffer
|
|
130
84
|
};
|
|
131
85
|
}
|
|
132
86
|
async function _writeStr(fd, data, position, encoding) {
|
|
133
|
-
|
|
87
|
+
warnNotImplemented("fs.promises.write");
|
|
134
88
|
return {
|
|
135
89
|
bytesWritten: 0,
|
|
136
90
|
buffer: data
|
|
137
91
|
};
|
|
138
92
|
}
|
|
139
93
|
async function rm(path, options) {
|
|
140
|
-
const file =
|
|
94
|
+
const file = Gio.File.new_for_path(path.toString());
|
|
141
95
|
const recursive = options?.recursive || false;
|
|
142
|
-
const dirent = new
|
|
96
|
+
const dirent = new Dirent(path.toString());
|
|
143
97
|
if (dirent.isDirectory()) {
|
|
144
|
-
const childFiles = await (
|
|
98
|
+
const childFiles = await readdir(path, { withFileTypes: true });
|
|
145
99
|
if (!recursive && childFiles.length) {
|
|
146
100
|
throw new Error("Dir is not empty!");
|
|
147
101
|
}
|
|
148
102
|
for (const childFile of childFiles) {
|
|
149
103
|
if (childFile.isDirectory()) {
|
|
150
|
-
await rmdir(
|
|
104
|
+
await rmdir(join(path.toString(), childFile.name), options);
|
|
151
105
|
} else if (childFile.isFile()) {
|
|
152
|
-
await rm(
|
|
106
|
+
await rm(join(path.toString(), childFile.name), options);
|
|
153
107
|
}
|
|
154
108
|
}
|
|
155
109
|
}
|
|
156
110
|
const ok = await new Promise((resolve, reject) => {
|
|
157
111
|
try {
|
|
158
|
-
file.delete_async(
|
|
112
|
+
file.delete_async(GLib.PRIORITY_DEFAULT, null, (self, res) => {
|
|
159
113
|
try {
|
|
160
114
|
resolve(file.delete_finish(res));
|
|
161
115
|
} catch (error) {
|
|
@@ -175,15 +129,32 @@ var promises_default = {
|
|
|
175
129
|
readFile,
|
|
176
130
|
mkdir,
|
|
177
131
|
mkdtemp,
|
|
178
|
-
realpath
|
|
179
|
-
readdir
|
|
132
|
+
realpath,
|
|
133
|
+
readdir,
|
|
180
134
|
writeFile,
|
|
181
135
|
rmdir,
|
|
182
136
|
unlink,
|
|
183
137
|
open,
|
|
184
138
|
write,
|
|
185
139
|
rm,
|
|
186
|
-
lstat
|
|
187
|
-
symlink
|
|
188
|
-
stat
|
|
140
|
+
lstat,
|
|
141
|
+
symlink,
|
|
142
|
+
stat
|
|
143
|
+
};
|
|
144
|
+
export {
|
|
145
|
+
promises_default as default,
|
|
146
|
+
lstat,
|
|
147
|
+
mkdir,
|
|
148
|
+
mkdtemp,
|
|
149
|
+
open,
|
|
150
|
+
readFile,
|
|
151
|
+
readdir,
|
|
152
|
+
realpath,
|
|
153
|
+
rm,
|
|
154
|
+
rmdir,
|
|
155
|
+
stat,
|
|
156
|
+
symlink,
|
|
157
|
+
unlink,
|
|
158
|
+
write,
|
|
159
|
+
writeFile
|
|
189
160
|
};
|
package/lib/cjs/read-stream.js
CHANGED
|
@@ -1,44 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var read_stream_exports = {};
|
|
29
|
-
__export(read_stream_exports, {
|
|
30
|
-
ReadStream: () => ReadStream,
|
|
31
|
-
createReadStream: () => createReadStream,
|
|
32
|
-
fromFileUrl: () => fromFileUrl
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(read_stream_exports);
|
|
35
|
-
var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
|
|
36
|
-
var import_utils = require("@gjsify/utils");
|
|
37
|
-
var import_buffer = require("buffer");
|
|
38
|
-
var import_stream = require("stream");
|
|
39
|
-
var import_url = require("url");
|
|
1
|
+
import GLib from "@girs/glib-2.0";
|
|
2
|
+
import { notImplemented } from "@gjsify/utils";
|
|
3
|
+
import { Buffer } from "buffer";
|
|
4
|
+
import { Readable } from "stream";
|
|
5
|
+
import { URL } from "url";
|
|
40
6
|
function fromFileUrl(url) {
|
|
41
|
-
url = url instanceof
|
|
7
|
+
url = url instanceof URL ? url : new URL(url);
|
|
42
8
|
if (url.protocol != "file:") {
|
|
43
9
|
throw new TypeError("Must be a file URL.");
|
|
44
10
|
}
|
|
@@ -46,9 +12,9 @@ function fromFileUrl(url) {
|
|
|
46
12
|
url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25")
|
|
47
13
|
);
|
|
48
14
|
}
|
|
49
|
-
class ReadStream extends
|
|
15
|
+
class ReadStream extends Readable {
|
|
50
16
|
close(callback) {
|
|
51
|
-
callback(
|
|
17
|
+
callback(notImplemented("ReadStream.close"));
|
|
52
18
|
}
|
|
53
19
|
/**
|
|
54
20
|
* The number of bytes that have been read so far.
|
|
@@ -69,14 +35,14 @@ class ReadStream extends import_stream.Readable {
|
|
|
69
35
|
*/
|
|
70
36
|
pending;
|
|
71
37
|
constructor(path, opts) {
|
|
72
|
-
path = path instanceof
|
|
38
|
+
path = path instanceof URL ? fromFileUrl(path) : path;
|
|
73
39
|
const hasBadOptions = opts && (opts.start || opts.end);
|
|
74
40
|
if (hasBadOptions) {
|
|
75
|
-
|
|
41
|
+
notImplemented(
|
|
76
42
|
`fs.ReadStream.prototype.constructor with unsupported options (${JSON.stringify(opts)})`
|
|
77
43
|
);
|
|
78
44
|
}
|
|
79
|
-
const file =
|
|
45
|
+
const file = GLib.IOChannel.new_file(path.toString(), "r");
|
|
80
46
|
const buffer = "";
|
|
81
47
|
super({
|
|
82
48
|
autoDestroy: true,
|
|
@@ -86,7 +52,7 @@ class ReadStream extends import_stream.Readable {
|
|
|
86
52
|
try {
|
|
87
53
|
let n = 0;
|
|
88
54
|
file.read(buffer, 16 * 1024, n);
|
|
89
|
-
this.push(n ?
|
|
55
|
+
this.push(n ? Buffer.from(buffer.slice(0, n)) : null);
|
|
90
56
|
} catch (err) {
|
|
91
57
|
this.destroy(err);
|
|
92
58
|
}
|
|
@@ -105,3 +71,8 @@ class ReadStream extends import_stream.Readable {
|
|
|
105
71
|
function createReadStream(path, options) {
|
|
106
72
|
return new ReadStream(path, options);
|
|
107
73
|
}
|
|
74
|
+
export {
|
|
75
|
+
ReadStream,
|
|
76
|
+
createReadStream,
|
|
77
|
+
fromFileUrl
|
|
78
|
+
};
|
package/lib/cjs/stats.js
CHANGED
|
@@ -1,39 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var stats_exports = {};
|
|
29
|
-
__export(stats_exports, {
|
|
30
|
-
Stats: () => Stats
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(stats_exports);
|
|
33
|
-
var import_gio_2 = __toESM(require("@girs/gio-2.0"), 1);
|
|
34
|
-
var import_dirent = require("./dirent.js");
|
|
35
|
-
var import_path = require("path");
|
|
36
|
-
class Stats extends import_dirent.Dirent {
|
|
1
|
+
import Gio from "@girs/gio-2.0";
|
|
2
|
+
import { Dirent } from "./dirent.js";
|
|
3
|
+
import { basename } from "path";
|
|
4
|
+
class Stats extends Dirent {
|
|
37
5
|
dev;
|
|
38
6
|
ino;
|
|
39
7
|
mode;
|
|
@@ -64,11 +32,14 @@ class Stats extends import_dirent.Dirent {
|
|
|
64
32
|
constructor(path, filename) {
|
|
65
33
|
const pathStr = path.toString();
|
|
66
34
|
if (!filename)
|
|
67
|
-
filename =
|
|
35
|
+
filename = basename(pathStr);
|
|
68
36
|
super(pathStr, filename);
|
|
69
37
|
if (!this._file) {
|
|
70
38
|
throw new TypeError("this._file is not defined!");
|
|
71
39
|
}
|
|
72
|
-
this._info = this._file.query_info("standard::",
|
|
40
|
+
this._info = this._file.query_info("standard::", Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
|
|
73
41
|
}
|
|
74
42
|
}
|
|
43
|
+
export {
|
|
44
|
+
Stats
|
|
45
|
+
};
|