summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/dts/lib.deno.ns.d.ts45
-rw-r--r--runtime/js/40_files.js9
-rw-r--r--runtime/js/40_process.js8
-rw-r--r--runtime/js/90_deno_ns.js1
4 files changed, 47 insertions, 16 deletions
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index ff8fbb741..70dd5f4bc 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -795,7 +795,7 @@ declare namespace Deno {
},
): IterableIterator<Uint8Array>;
- /** Synchronously open a file and return an instance of `Deno.File`. The
+ /** Synchronously open a file and return an instance of `Deno.FsFile`. The
* file does not need to previously exist if using the `create` or `createNew`
* open options. It is the callers responsibility to close the file when finished
* with it.
@@ -808,9 +808,9 @@ declare namespace Deno {
*
* Requires `allow-read` and/or `allow-write` permissions depending on options.
*/
- export function openSync(path: string | URL, options?: OpenOptions): File;
+ export function openSync(path: string | URL, options?: OpenOptions): FsFile;
- /** Open a file and resolve to an instance of `Deno.File`. The
+ /** Open a file and resolve to an instance of `Deno.FsFile`. The
* file does not need to previously exist if using the `create` or `createNew`
* open options. It is the callers responsibility to close the file when finished
* with it.
@@ -826,10 +826,10 @@ declare namespace Deno {
export function open(
path: string | URL,
options?: OpenOptions,
- ): Promise<File>;
+ ): Promise<FsFile>;
/** Creates a file if none exists or truncates an existing file and returns
- * an instance of `Deno.File`.
+ * an instance of `Deno.FsFile`.
*
* ```ts
* const file = Deno.createSync("/foo/bar.txt");
@@ -837,10 +837,10 @@ declare namespace Deno {
*
* Requires `allow-read` and `allow-write` permissions.
*/
- export function createSync(path: string | URL): File;
+ export function createSync(path: string | URL): FsFile;
/** Creates a file if none exists or truncates an existing file and resolves to
- * an instance of `Deno.File`.
+ * an instance of `Deno.FsFile`.
*
* ```ts
* const file = await Deno.create("/foo/bar.txt");
@@ -848,7 +848,7 @@ declare namespace Deno {
*
* Requires `allow-read` and `allow-write` permissions.
*/
- export function create(path: string | URL): Promise<File>;
+ export function create(path: string | URL): Promise<FsFile>;
/** Synchronously read from a resource ID (`rid`) into an array buffer (`buffer`).
*
@@ -1070,6 +1070,35 @@ declare namespace Deno {
export function close(rid: number): void;
/** The Deno abstraction for reading and writing files. */
+ export class FsFile
+ implements
+ Reader,
+ ReaderSync,
+ Writer,
+ WriterSync,
+ Seeker,
+ SeekerSync,
+ Closer {
+ readonly rid: number;
+ constructor(rid: number);
+ write(p: Uint8Array): Promise<number>;
+ writeSync(p: Uint8Array): number;
+ truncate(len?: number): Promise<void>;
+ truncateSync(len?: number): void;
+ read(p: Uint8Array): Promise<number | null>;
+ readSync(p: Uint8Array): number | null;
+ seek(offset: number, whence: SeekMode): Promise<number>;
+ seekSync(offset: number, whence: SeekMode): number;
+ stat(): Promise<FileInfo>;
+ statSync(): FileInfo;
+ close(): void;
+ }
+
+ /**
+ * @deprecated Use `Deno.FsFile` instead. `Deno.File` will be removed in Deno 2.0.
+ *
+ * The Deno abstraction for reading and writing files.
+ */
export class File
implements
Reader,
diff --git a/runtime/js/40_files.js b/runtime/js/40_files.js
index b0d651d5c..8aa0a4972 100644
--- a/runtime/js/40_files.js
+++ b/runtime/js/40_files.js
@@ -41,7 +41,7 @@
{ path: pathFromURL(path), options, mode },
);
- return new File(rid);
+ return new FsFile(rid);
}
async function open(
@@ -55,7 +55,7 @@
{ path: pathFromURL(path), options, mode },
);
- return new File(rid);
+ return new FsFile(rid);
}
function createSync(path) {
@@ -76,7 +76,7 @@
});
}
- class File {
+ class FsFile {
#rid = 0;
#readable;
@@ -272,7 +272,8 @@
stdin,
stdout,
stderr,
- File,
+ File: FsFile,
+ FsFile,
create,
createSync,
open,
diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js
index 8d9f402ff..14c31fa8d 100644
--- a/runtime/js/40_process.js
+++ b/runtime/js/40_process.js
@@ -3,7 +3,7 @@
((window) => {
const core = window.Deno.core;
- const { File } = window.__bootstrap.files;
+ const { FsFile } = window.__bootstrap.files;
const { readAll } = window.__bootstrap.io;
const { assert, pathFromURL } = window.__bootstrap.util;
const {
@@ -46,15 +46,15 @@
this.pid = res.pid;
if (res.stdinRid && res.stdinRid > 0) {
- this.stdin = new File(res.stdinRid);
+ this.stdin = new FsFile(res.stdinRid);
}
if (res.stdoutRid && res.stdoutRid > 0) {
- this.stdout = new File(res.stdoutRid);
+ this.stdout = new FsFile(res.stdoutRid);
}
if (res.stderrRid && res.stderrRid > 0) {
- this.stderr = new File(res.stderrRid);
+ this.stderr = new FsFile(res.stderrRid);
}
}
diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js
index 871062394..d52f267c0 100644
--- a/runtime/js/90_deno_ns.js
+++ b/runtime/js/90_deno_ns.js
@@ -76,6 +76,7 @@
write: __bootstrap.io.write,
writeSync: __bootstrap.io.writeSync,
File: __bootstrap.files.File,
+ FsFile: __bootstrap.files.FsFile,
open: __bootstrap.files.open,
openSync: __bootstrap.files.openSync,
create: __bootstrap.files.create,