@gjsify/fs 0.0.2 → 0.0.4

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.
@@ -1,43 +1,12 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var callback_exports = {};
19
- __export(callback_exports, {
20
- close: () => close,
21
- lstat: () => import_fs_lstat.lstat,
22
- open: () => open,
23
- read: () => read,
24
- readdir: () => import_fs_readdir.readdir,
25
- realpath: () => import_fs_realpath.realpath,
26
- rm: () => rm,
27
- stat: () => import_fs_stat.stat,
28
- symlink: () => import_fs_symlink.symlink,
29
- write: () => write
30
- });
31
- module.exports = __toCommonJS(callback_exports);
32
- var import_promises = require("./promises.js");
33
- var import_utils = require("@gjsify/utils");
34
- var import_file_handle = require("./file-handle.js");
35
- var import_buffer = require("buffer");
36
- var import_fs_realpath = require("@gjsify/deno_std/node/_fs/_fs_realpath");
37
- var import_fs_readdir = require("@gjsify/deno_std/node/_fs/_fs_readdir");
38
- var import_fs_symlink = require("@gjsify/deno_std/node/_fs/_fs_symlink");
39
- var import_fs_lstat = require("@gjsify/deno_std/node/_fs/_fs_lstat");
40
- var import_fs_stat = require("@gjsify/deno_std/node/_fs/_fs_stat");
1
+ import { open as openP, rm as rmP } from "./promises.js";
2
+ import { warnNotImplemented } from "@gjsify/utils";
3
+ import { FileHandle } from "./file-handle.js";
4
+ import { Buffer } from "buffer";
5
+ import { realpath } from "@gjsify/deno_std/node/_fs/_fs_realpath";
6
+ import { readdir } from "@gjsify/deno_std/node/_fs/_fs_readdir";
7
+ import { symlink } from "@gjsify/deno_std/node/_fs/_fs_symlink";
8
+ import { lstat } from "@gjsify/deno_std/node/_fs/_fs_lstat";
9
+ import { stat } from "@gjsify/deno_std/node/_fs/_fs_stat";
41
10
  function open(path, ...args) {
42
11
  let flags;
43
12
  let mode;
@@ -58,14 +27,14 @@ function open(path, ...args) {
58
27
  default:
59
28
  break;
60
29
  }
61
- (0, import_promises.open)(path, flags, mode).then((fileHandle) => {
30
+ openP(path, flags, mode).then((fileHandle) => {
62
31
  callback(null, fileHandle.fd);
63
32
  }).catch((err) => {
64
33
  callback(err, -1);
65
34
  });
66
35
  }
67
36
  function write(fd, data, ...args) {
68
- const fileHandle = import_file_handle.FileHandle.getInstance(fd);
37
+ const fileHandle = FileHandle.getInstance(fd);
69
38
  if (typeof data === "string") {
70
39
  const callback2 = args[args.length - 1];
71
40
  fileHandle.write(data, ...args.pop()).then((res) => {
@@ -82,14 +51,14 @@ function write(fd, data, ...args) {
82
51
  fileHandle.write(data, offset, length, position).then((res) => {
83
52
  callback(null, res.bytesWritten, res.buffer);
84
53
  }).catch((err) => {
85
- callback(err, 0, import_buffer.Buffer.from([]));
54
+ callback(err, 0, Buffer.from([]));
86
55
  });
87
56
  }
88
57
  function read(fd, ...args) {
89
- const fileHandle = import_file_handle.FileHandle.getInstance(fd);
58
+ const fileHandle = FileHandle.getInstance(fd);
90
59
  const callback = args[args.length - 1];
91
- const err = new Error((0, import_utils.warnNotImplemented)("fs.read"));
92
- callback(err, 0, import_buffer.Buffer.from(""));
60
+ const err = new Error(warnNotImplemented("fs.read"));
61
+ callback(err, 0, Buffer.from(""));
93
62
  let buffer;
94
63
  let offset;
95
64
  let length;
@@ -109,11 +78,11 @@ function read(fd, ...args) {
109
78
  fileHandle.read(buffer, offset, length, position).then((res) => {
110
79
  callback(null, res.bytesRead, res.buffer);
111
80
  }).catch((err2) => {
112
- callback(err2, 0, import_buffer.Buffer.from([]));
81
+ callback(err2, 0, Buffer.from([]));
113
82
  });
114
83
  }
115
84
  function close(fd, callback) {
116
- import_file_handle.FileHandle.getInstance(fd).close().then(() => {
85
+ FileHandle.getInstance(fd).close().then(() => {
117
86
  callback(null);
118
87
  }).catch((err) => callback(err));
119
88
  }
@@ -123,9 +92,21 @@ function rm(path, ...args) {
123
92
  if (args.length >= 2) {
124
93
  options = args[0];
125
94
  }
126
- (0, import_promises.rm)(path, options).then(() => {
95
+ rmP(path, options).then(() => {
127
96
  callback(null);
128
97
  }).catch((err) => {
129
98
  callback(err);
130
99
  });
131
100
  }
101
+ export {
102
+ close,
103
+ lstat,
104
+ open,
105
+ read,
106
+ readdir,
107
+ realpath,
108
+ rm,
109
+ stat,
110
+ symlink,
111
+ write
112
+ };
package/lib/cjs/dirent.js CHANGED
@@ -1,37 +1,5 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
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 dirent_exports = {};
29
- __export(dirent_exports, {
30
- Dirent: () => Dirent
31
- });
32
- module.exports = __toCommonJS(dirent_exports);
33
- var import_gio_2 = __toESM(require("@girs/gio-2.0"), 1);
34
- var import_path = require("path");
1
+ import Gio from "@girs/gio-2.0";
2
+ import { basename } from "path";
35
3
  class Dirent {
36
4
  /**
37
5
  * The file name that this `fs.Dirent` object refers to. The type of this
@@ -51,25 +19,25 @@ class Dirent {
51
19
  /** This is not part of node.fs and is used internal by gjsify */
52
20
  constructor(path, filename) {
53
21
  if (!filename)
54
- filename = (0, import_path.basename)(path);
22
+ filename = basename(path);
55
23
  this.name = filename;
56
- this._file = import_gio_2.default.File.new_for_path(path);
57
- const type = this._file.query_file_type(import_gio_2.default.FileQueryInfoFlags.NONE, null);
24
+ this._file = Gio.File.new_for_path(path);
25
+ const type = this._file.query_file_type(Gio.FileQueryInfoFlags.NONE, null);
58
26
  switch (type) {
59
- case import_gio_2.default.FileType.DIRECTORY:
27
+ case Gio.FileType.DIRECTORY:
60
28
  this._isDirectory = true;
61
29
  break;
62
- case import_gio_2.default.FileType.MOUNTABLE:
30
+ case Gio.FileType.MOUNTABLE:
63
31
  break;
64
- case import_gio_2.default.FileType.REGULAR:
32
+ case Gio.FileType.REGULAR:
65
33
  this._isFile = true;
66
34
  break;
67
- case import_gio_2.default.FileType.SYMBOLIC_LINK:
68
- case import_gio_2.default.FileType.SHORTCUT:
35
+ case Gio.FileType.SYMBOLIC_LINK:
36
+ case Gio.FileType.SHORTCUT:
69
37
  this._isSymbolicLink = true;
70
38
  break;
71
- case import_gio_2.default.FileType.SPECIAL:
72
- this._isBlockDevice = import_gio_2.default.unix_is_system_device_path(path);
39
+ case Gio.FileType.SPECIAL:
40
+ this._isBlockDevice = Gio.unix_is_system_device_path(path);
73
41
  break;
74
42
  }
75
43
  }
@@ -125,3 +93,6 @@ class Dirent {
125
93
  return this._isSocket;
126
94
  }
127
95
  }
96
+ export {
97
+ Dirent
98
+ };
@@ -1,28 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var encoding_exports = {};
19
- __export(encoding_exports, {
20
- decode: () => decode,
21
- encodeUint8Array: () => encodeUint8Array,
22
- getEncodingFromOptions: () => getEncodingFromOptions
23
- });
24
- module.exports = __toCommonJS(encoding_exports);
25
- var import_buffer = require("buffer");
1
+ import { Buffer } from "buffer";
26
2
  function getEncodingFromOptions(options = { encoding: null, flag: "r" }, defaultEncoding = "utf8") {
27
3
  if (options === null) {
28
4
  return defaultEncoding;
@@ -37,7 +13,7 @@ function getEncodingFromOptions(options = { encoding: null, flag: "r" }, default
37
13
  }
38
14
  function encodeUint8Array(encoding, data) {
39
15
  if (encoding === "buffer") {
40
- return import_buffer.Buffer.from(data);
16
+ return Buffer.from(data);
41
17
  }
42
18
  const decoder = new TextDecoder(encoding);
43
19
  return decoder.decode(data);
@@ -51,3 +27,8 @@ function decode(str, encoding) {
51
27
  return decoder.decode(encoder.encode(str));
52
28
  }
53
29
  }
30
+ export {
31
+ decode,
32
+ encodeUint8Array,
33
+ getEncodingFromOptions
34
+ };
@@ -1,49 +1,17 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
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 file_handle_exports = {};
29
- __export(file_handle_exports, {
30
- FileHandle: () => FileHandle
31
- });
32
- module.exports = __toCommonJS(file_handle_exports);
33
- var import_utils = require("@gjsify/utils");
34
- var import_read_stream = require("./read-stream.js");
35
- var import_write_stream = require("./write-stream.js");
36
- var import_stats = require("./stats.js");
37
- var import_encoding = require("./encoding.js");
38
- var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
39
- var import_web = require("stream/web");
40
- var import_buffer = require("buffer");
1
+ import { warnNotImplemented, notImplemented } from "@gjsify/utils";
2
+ import { ReadStream } from "./read-stream.js";
3
+ import { WriteStream } from "./write-stream.js";
4
+ import { Stats } from "./stats.js";
5
+ import { getEncodingFromOptions, encodeUint8Array } from "./encoding.js";
6
+ import GLib from "@girs/glib-2.0";
7
+ import { ReadableStream } from "stream/web";
8
+ import { Buffer } from "buffer";
41
9
  class FileHandle {
42
10
  constructor(options) {
43
11
  this.options = options;
44
12
  this.options.flags ||= "r";
45
13
  this.options.mode ||= 438;
46
- this._file = import_glib_2.default.IOChannel.new_file(options.path.toString(), this.options.flags);
14
+ this._file = GLib.IOChannel.new_file(options.path.toString(), this.options.flags);
47
15
  this.fd = this._file.unix_get_fd();
48
16
  FileHandle.instances[this.fd] = this;
49
17
  return FileHandle.getInstance(this.fd);
@@ -74,14 +42,14 @@ class FileHandle {
74
42
  * @return Fulfills with `undefined` upon success.
75
43
  */
76
44
  async appendFile(data, options) {
77
- const encoding = (0, import_encoding.getEncodingFromOptions)(options);
45
+ const encoding = getEncodingFromOptions(options);
78
46
  if (typeof data === "string") {
79
- data = import_buffer.Buffer.from(data);
47
+ data = Buffer.from(data);
80
48
  }
81
49
  if (encoding)
82
50
  this._file.set_encoding(encoding);
83
51
  const [status, written] = this._file.write_chars(data, data.length);
84
- if (status === import_glib_2.default.IOStatus.ERROR) {
52
+ if (status === GLib.IOStatus.ERROR) {
85
53
  throw new Error("Error on append to file!");
86
54
  }
87
55
  }
@@ -93,7 +61,7 @@ class FileHandle {
93
61
  * @return Fulfills with `undefined` upon success.
94
62
  */
95
63
  async chown(uid, gid) {
96
- (0, import_utils.warnNotImplemented)("fs.FileHandle.chown");
64
+ warnNotImplemented("fs.FileHandle.chown");
97
65
  }
98
66
  /**
99
67
  * Modifies the permissions on the file. See [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html).
@@ -102,7 +70,7 @@ class FileHandle {
102
70
  * @return Fulfills with `undefined` upon success.
103
71
  */
104
72
  async chmod(mode) {
105
- (0, import_utils.warnNotImplemented)("fs.FileHandle.chmod");
73
+ warnNotImplemented("fs.FileHandle.chmod");
106
74
  }
107
75
  /**
108
76
  * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream
@@ -158,7 +126,7 @@ class FileHandle {
158
126
  * @since v16.11.0
159
127
  */
160
128
  createReadStream(options) {
161
- return new import_read_stream.ReadStream(this.options.path, options);
129
+ return new ReadStream(this.options.path, options);
162
130
  }
163
131
  /**
164
132
  * `options` may also include a `start` option to allow writing data at some
@@ -177,7 +145,7 @@ class FileHandle {
177
145
  * @since v16.11.0
178
146
  */
179
147
  createWriteStream(options) {
180
- return new import_write_stream.WriteStream(this.options.path, options);
148
+ return new WriteStream(this.options.path, options);
181
149
  }
182
150
  /**
183
151
  * Forces all currently queued I/O operations associated with the file to the
@@ -188,7 +156,7 @@ class FileHandle {
188
156
  * @return Fulfills with `undefined` upon success.
189
157
  */
190
158
  async datasync() {
191
- (0, import_utils.warnNotImplemented)("fs.FileHandle.datasync");
159
+ warnNotImplemented("fs.FileHandle.datasync");
192
160
  }
193
161
  /**
194
162
  * Request that all data for the open file descriptor is flushed to the storage
@@ -198,7 +166,7 @@ class FileHandle {
198
166
  * @return Fufills with `undefined` upon success.
199
167
  */
200
168
  async sync() {
201
- (0, import_utils.warnNotImplemented)("fs.FileHandle.sync");
169
+ warnNotImplemented("fs.FileHandle.sync");
202
170
  }
203
171
  async read(args) {
204
172
  let buffer;
@@ -218,21 +186,21 @@ class FileHandle {
218
186
  position = args[3];
219
187
  }
220
188
  if (offset) {
221
- const status2 = this._file.seek_position(offset, import_glib_2.default.SeekType.CUR);
222
- if (status2 === import_glib_2.default.IOStatus.ERROR) {
189
+ const status2 = this._file.seek_position(offset, GLib.SeekType.CUR);
190
+ if (status2 === GLib.IOStatus.ERROR) {
223
191
  throw new Error("Error on set offset!");
224
192
  }
225
193
  }
226
194
  if (length)
227
195
  this._file.set_buffer_size(length);
228
196
  if (position) {
229
- const status2 = this._file.seek_position(position, import_glib_2.default.SeekType.SET);
230
- if (status2 === import_glib_2.default.IOStatus.ERROR) {
197
+ const status2 = this._file.seek_position(position, GLib.SeekType.SET);
198
+ if (status2 === GLib.IOStatus.ERROR) {
231
199
  throw new Error("Error on set position!");
232
200
  }
233
201
  }
234
202
  const [status, buf, bytesRead] = this._file.read_chars();
235
- if (status === import_glib_2.default.IOStatus.ERROR) {
203
+ if (status === GLib.IOStatus.ERROR) {
236
204
  throw new Error("Error on read!");
237
205
  }
238
206
  buffer = buf;
@@ -264,7 +232,7 @@ class FileHandle {
264
232
  * @experimental
265
233
  */
266
234
  readableWebStream() {
267
- return new import_web.ReadableStream();
235
+ return new ReadableStream();
268
236
  }
269
237
  /**
270
238
  * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
@@ -273,14 +241,14 @@ class FileHandle {
273
241
  * If a flag is not provided, it defaults to `'r'`.
274
242
  */
275
243
  async readFile(options) {
276
- const encoding = (0, import_encoding.getEncodingFromOptions)(options, "buffer");
244
+ const encoding = getEncodingFromOptions(options, "buffer");
277
245
  if (encoding)
278
246
  this._file.set_encoding(encoding);
279
247
  const [status, buf] = this._file.read_to_end();
280
- if (status === import_glib_2.default.IOStatus.ERROR) {
248
+ if (status === GLib.IOStatus.ERROR) {
281
249
  throw new Error("Error on read from file!");
282
250
  }
283
- const res = (0, import_encoding.encodeUint8Array)(encoding, buf);
251
+ const res = encodeUint8Array(encoding, buf);
284
252
  return res;
285
253
  }
286
254
  /**
@@ -300,11 +268,11 @@ class FileHandle {
300
268
  * @param options See `filehandle.createReadStream()` for the options.
301
269
  */
302
270
  readLines(options) {
303
- (0, import_utils.notImplemented)("fs.FileHandle.readLines");
271
+ notImplemented("fs.FileHandle.readLines");
304
272
  }
305
273
  async stat(opts) {
306
- (0, import_utils.warnNotImplemented)("fs.FileHandle.stat");
307
- return new import_stats.Stats(this.options.path.toString());
274
+ warnNotImplemented("fs.FileHandle.stat");
275
+ return new Stats(this.options.path.toString());
308
276
  }
309
277
  /**
310
278
  * Truncates the file.
@@ -335,14 +303,14 @@ class FileHandle {
335
303
  * @return Fulfills with `undefined` upon success.
336
304
  */
337
305
  async truncate(len) {
338
- (0, import_utils.warnNotImplemented)("fs.FileHandle.truncate");
306
+ warnNotImplemented("fs.FileHandle.truncate");
339
307
  }
340
308
  /**
341
309
  * Change the file system timestamps of the object referenced by the `FileHandle` then resolves the promise with no arguments upon success.
342
310
  * @since v10.0.0
343
311
  */
344
312
  async utimes(atime, mtime) {
345
- (0, import_utils.warnNotImplemented)("fs.FileHandle.utimes");
313
+ warnNotImplemented("fs.FileHandle.utimes");
346
314
  }
347
315
  /**
348
316
  * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
@@ -363,7 +331,7 @@ class FileHandle {
363
331
  * @since v10.0.0
364
332
  */
365
333
  async writeFile(data, options) {
366
- (0, import_utils.warnNotImplemented)("fs.FileHandle.writeFile");
334
+ warnNotImplemented("fs.FileHandle.writeFile");
367
335
  }
368
336
  async write(data, ...args) {
369
337
  let position = null;
@@ -378,22 +346,22 @@ class FileHandle {
378
346
  length = args[1];
379
347
  position = args[2];
380
348
  }
381
- encoding = (0, import_encoding.getEncodingFromOptions)(encoding, typeof data === "string" ? "utf8" : null);
349
+ encoding = getEncodingFromOptions(encoding, typeof data === "string" ? "utf8" : null);
382
350
  if (encoding) {
383
351
  console.log("set_encoding", encoding, this._file.get_encoding(), typeof data);
384
352
  this._file.set_encoding(encoding === "buffer" ? null : encoding);
385
353
  }
386
354
  if (offset) {
387
- const status2 = this._file.seek_position(offset, import_glib_2.default.SeekType.CUR);
388
- if (status2 === import_glib_2.default.IOStatus.ERROR) {
355
+ const status2 = this._file.seek_position(offset, GLib.SeekType.CUR);
356
+ if (status2 === GLib.IOStatus.ERROR) {
389
357
  throw new Error("Error on set offset!");
390
358
  }
391
359
  }
392
360
  if (length)
393
361
  this._file.set_buffer_size(length);
394
362
  if (position) {
395
- const status2 = this._file.seek_position(position, import_glib_2.default.SeekType.SET);
396
- if (status2 === import_glib_2.default.IOStatus.ERROR) {
363
+ const status2 = this._file.seek_position(position, GLib.SeekType.SET);
364
+ if (status2 === GLib.IOStatus.ERROR) {
397
365
  throw new Error("Error on set position!");
398
366
  }
399
367
  }
@@ -407,7 +375,7 @@ class FileHandle {
407
375
  bytesWritten = _bytesWritten;
408
376
  status = _status;
409
377
  }
410
- if (status === import_glib_2.default.IOStatus.ERROR) {
378
+ if (status === GLib.IOStatus.ERROR) {
411
379
  throw new Error("Error on write to file!");
412
380
  }
413
381
  return {
@@ -431,7 +399,7 @@ class FileHandle {
431
399
  * position.
432
400
  */
433
401
  async writev(buffers, position) {
434
- (0, import_utils.warnNotImplemented)("fs.FileHandle.writev");
402
+ warnNotImplemented("fs.FileHandle.writev");
435
403
  return {
436
404
  bytesWritten: 0,
437
405
  buffers: []
@@ -444,7 +412,7 @@ class FileHandle {
444
412
  * @return Fulfills upon success an object containing two properties:
445
413
  */
446
414
  async readv(buffers, position) {
447
- (0, import_utils.warnNotImplemented)("fs.FileHandle.readv");
415
+ warnNotImplemented("fs.FileHandle.readv");
448
416
  return {
449
417
  bytesRead: 0,
450
418
  buffers: []
@@ -471,3 +439,6 @@ class FileHandle {
471
439
  this._file.close();
472
440
  }
473
441
  }
442
+ export {
443
+ FileHandle
444
+ };
@@ -1,47 +1,14 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
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 fs_watcher_exports = {};
29
- __export(fs_watcher_exports, {
30
- FSWatcher: () => FSWatcher,
31
- default: () => fs_watcher_default
32
- });
33
- module.exports = __toCommonJS(fs_watcher_exports);
34
- var import_gio_2 = __toESM(require("@girs/gio-2.0"), 1);
35
- var import_events = require("events");
1
+ import Gio from "@girs/gio-2.0";
2
+ import { EventEmitter } from "events";
36
3
  const privates = /* @__PURE__ */ new WeakMap();
37
- class FSWatcher extends import_events.EventEmitter {
4
+ class FSWatcher extends EventEmitter {
38
5
  constructor(filename, options, listener) {
39
6
  super();
40
7
  if (!options || typeof options !== "object")
41
8
  options = { persistent: true };
42
- const cancellable = import_gio_2.default.Cancellable.new();
43
- const file = import_gio_2.default.File.new_for_path(filename);
44
- const watcher = file.monitor(import_gio_2.default.FileMonitorFlags.NONE, cancellable);
9
+ const cancellable = Gio.Cancellable.new();
10
+ const file = Gio.File.new_for_path(filename);
11
+ const watcher = file.monitor(Gio.FileMonitorFlags.NONE, cancellable);
45
12
  watcher.connect("changed", changed.bind(this));
46
13
  privates.set(this, {
47
14
  persistent: options.persistent,
@@ -64,16 +31,20 @@ class FSWatcher extends import_events.EventEmitter {
64
31
  ;
65
32
  function changed(watcher, file, otherFile, eventType) {
66
33
  switch (eventType) {
67
- case import_gio_2.default.FileMonitorEvent.CHANGES_DONE_HINT:
34
+ case Gio.FileMonitorEvent.CHANGES_DONE_HINT:
68
35
  this.emit("change", "change", file.get_basename());
69
36
  break;
70
- case import_gio_2.default.FileMonitorEvent.DELETED:
71
- case import_gio_2.default.FileMonitorEvent.CREATED:
72
- case import_gio_2.default.FileMonitorEvent.RENAMED:
73
- case import_gio_2.default.FileMonitorEvent.MOVED_IN:
74
- case import_gio_2.default.FileMonitorEvent.MOVED_OUT:
37
+ case Gio.FileMonitorEvent.DELETED:
38
+ case Gio.FileMonitorEvent.CREATED:
39
+ case Gio.FileMonitorEvent.RENAMED:
40
+ case Gio.FileMonitorEvent.MOVED_IN:
41
+ case Gio.FileMonitorEvent.MOVED_OUT:
75
42
  this.emit("rename", "rename", file.get_basename());
76
43
  break;
77
44
  }
78
45
  }
79
46
  var fs_watcher_default = FSWatcher;
47
+ export {
48
+ FSWatcher,
49
+ fs_watcher_default as default
50
+ };