diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-04-12 17:27:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-12 11:27:38 +0200 |
commit | 875ac73f1e8459ecec3d0d7b275546740bfe007e (patch) | |
tree | 6dba077c5e8a50599e1d6ed9837cdb54ea5198ce | |
parent | bf99039ea944c32f0247ad8b3d1057f20f921b40 (diff) |
feat(runtime): stabilize Deno.fstat and Deno.fstatSync (#10108)
This commit stabilizes Deno.fstat and Deno.fstatSync
which are well known system calls and have a stable interface.
-rw-r--r-- | cli/diagnostics.rs | 2 | ||||
-rw-r--r-- | cli/dts/lib.deno.ns.d.ts | 22 | ||||
-rw-r--r-- | cli/dts/lib.deno.unstable.d.ts | 22 | ||||
-rw-r--r-- | runtime/js/90_deno_ns.js | 4 | ||||
-rw-r--r-- | runtime/ops/fs.rs | 2 |
5 files changed, 24 insertions, 28 deletions
diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs index f24a2e21d..b7327d72c 100644 --- a/cli/diagnostics.rs +++ b/cli/diagnostics.rs @@ -48,8 +48,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[ "createHttpClient", "emit", "formatDiagnostics", - "fstat", - "fstatSync", "futime", "futimeSync", "hostname", diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts index 931d28877..7d248e4b2 100644 --- a/cli/dts/lib.deno.ns.d.ts +++ b/cli/dts/lib.deno.ns.d.ts @@ -2386,4 +2386,26 @@ declare namespace Deno { * ``` */ export function ftruncate(rid: number, len?: number): Promise<void>; + + /** + * Synchronously returns a `Deno.FileInfo` for the given file stream. + * + * ```ts + * const file = Deno.openSync("file.txt", { read: true }); + * const fileInfo = Deno.fstatSync(file.rid); + * assert(fileInfo.isFile); + * ``` + */ + export function fstatSync(rid: number): FileInfo; + + /** + * Returns a `Deno.FileInfo` for the given file stream. + * + * ```ts + * const file = await Deno.open("file.txt", { read: true }); + * const fileInfo = await Deno.fstat(file.rid); + * assert(fileInfo.isFile); + * ``` + */ + export function fstat(rid: number): Promise<FileInfo>; } diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 612ebeccc..508e1ca6c 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -1043,28 +1043,6 @@ declare namespace Deno { export function hostname(): string; /** **UNSTABLE**: New API, yet to be vetted. - * Synchronously returns a `Deno.FileInfo` for the given file stream. - * - * ```ts - * const file = Deno.openSync("file.txt", { read: true }); - * const fileInfo = Deno.fstatSync(file.rid); - * assert(fileInfo.isFile); - * ``` - */ - export function fstatSync(rid: number): FileInfo; - - /** **UNSTABLE**: New API, yet to be vetted. - * Returns a `Deno.FileInfo` for the given file stream. - * - * ```ts - * const file = await Deno.open("file.txt", { read: true }); - * const fileInfo = await Deno.fstat(file.rid); - * assert(fileInfo.isFile); - * ``` - */ - export function fstat(rid: number): Promise<FileInfo>; - - /** **UNSTABLE**: New API, yet to be vetted. * The pid of the current process's parent. */ export const ppid: number; diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 3c13489c7..f563a20fe 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -86,6 +86,8 @@ connectTls: __bootstrap.tls.connectTls, listenTls: __bootstrap.tls.listenTls, sleepSync: __bootstrap.timers.sleepSync, + fstatSync: __bootstrap.fs.fstatSync, + fstat: __bootstrap.fs.fstat, fsyncSync: __bootstrap.fs.fsyncSync, fsync: __bootstrap.fs.fsync, fdatasyncSync: __bootstrap.fs.fdatasyncSync, @@ -124,8 +126,6 @@ listenDatagram: __bootstrap.netUnstable.listenDatagram, serveHttp: __bootstrap.http.serveHttp, startTls: __bootstrap.tls.startTls, - fstatSync: __bootstrap.fs.fstatSync, - fstat: __bootstrap.fs.fstat, umask: __bootstrap.fs.umask, futime: __bootstrap.fs.futime, futimeSync: __bootstrap.fs.futimeSync, diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs index 0753ea0fb..aa3780624 100644 --- a/runtime/ops/fs.rs +++ b/runtime/ops/fs.rs @@ -338,7 +338,6 @@ fn op_fstat_sync( rid: ResourceId, _zero_copy: Option<ZeroCopyBuf>, ) -> Result<FsStat, AnyError> { - super::check_unstable(state, "Deno.fstat"); let metadata = StdFileResource::with(state, rid, |r| match r { Ok(std_file) => std_file.metadata().map_err(AnyError::from), Err(_) => Err(type_error("cannot stat this type of resource".to_string())), @@ -351,7 +350,6 @@ async fn op_fstat_async( rid: ResourceId, _zero_copy: Option<ZeroCopyBuf>, ) -> Result<FsStat, AnyError> { - super::check_unstable2(&state, "Deno.fstat"); let resource = state .borrow_mut() .resource_table |