mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -05:00
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.
This commit is contained in:
parent
bf99039ea9
commit
875ac73f1e
5 changed files with 24 additions and 28 deletions
|
@ -48,8 +48,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
|
|||
"createHttpClient",
|
||||
"emit",
|
||||
"formatDiagnostics",
|
||||
"fstat",
|
||||
"fstatSync",
|
||||
"futime",
|
||||
"futimeSync",
|
||||
"hostname",
|
||||
|
|
22
cli/dts/lib.deno.ns.d.ts
vendored
22
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -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>;
|
||||
}
|
||||
|
|
22
cli/dts/lib.deno.unstable.d.ts
vendored
22
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -1042,28 +1042,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.
|
||||
*/
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue