mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -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",
|
"createHttpClient",
|
||||||
"emit",
|
"emit",
|
||||||
"formatDiagnostics",
|
"formatDiagnostics",
|
||||||
"fstat",
|
|
||||||
"fstatSync",
|
|
||||||
"futime",
|
"futime",
|
||||||
"futimeSync",
|
"futimeSync",
|
||||||
"hostname",
|
"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>;
|
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;
|
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.
|
/** **UNSTABLE**: New API, yet to be vetted.
|
||||||
* The pid of the current process's parent.
|
* The pid of the current process's parent.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -86,6 +86,8 @@
|
||||||
connectTls: __bootstrap.tls.connectTls,
|
connectTls: __bootstrap.tls.connectTls,
|
||||||
listenTls: __bootstrap.tls.listenTls,
|
listenTls: __bootstrap.tls.listenTls,
|
||||||
sleepSync: __bootstrap.timers.sleepSync,
|
sleepSync: __bootstrap.timers.sleepSync,
|
||||||
|
fstatSync: __bootstrap.fs.fstatSync,
|
||||||
|
fstat: __bootstrap.fs.fstat,
|
||||||
fsyncSync: __bootstrap.fs.fsyncSync,
|
fsyncSync: __bootstrap.fs.fsyncSync,
|
||||||
fsync: __bootstrap.fs.fsync,
|
fsync: __bootstrap.fs.fsync,
|
||||||
fdatasyncSync: __bootstrap.fs.fdatasyncSync,
|
fdatasyncSync: __bootstrap.fs.fdatasyncSync,
|
||||||
|
@ -124,8 +126,6 @@
|
||||||
listenDatagram: __bootstrap.netUnstable.listenDatagram,
|
listenDatagram: __bootstrap.netUnstable.listenDatagram,
|
||||||
serveHttp: __bootstrap.http.serveHttp,
|
serveHttp: __bootstrap.http.serveHttp,
|
||||||
startTls: __bootstrap.tls.startTls,
|
startTls: __bootstrap.tls.startTls,
|
||||||
fstatSync: __bootstrap.fs.fstatSync,
|
|
||||||
fstat: __bootstrap.fs.fstat,
|
|
||||||
umask: __bootstrap.fs.umask,
|
umask: __bootstrap.fs.umask,
|
||||||
futime: __bootstrap.fs.futime,
|
futime: __bootstrap.fs.futime,
|
||||||
futimeSync: __bootstrap.fs.futimeSync,
|
futimeSync: __bootstrap.fs.futimeSync,
|
||||||
|
|
|
@ -338,7 +338,6 @@ fn op_fstat_sync(
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_zero_copy: Option<ZeroCopyBuf>,
|
_zero_copy: Option<ZeroCopyBuf>,
|
||||||
) -> Result<FsStat, AnyError> {
|
) -> Result<FsStat, AnyError> {
|
||||||
super::check_unstable(state, "Deno.fstat");
|
|
||||||
let metadata = StdFileResource::with(state, rid, |r| match r {
|
let metadata = StdFileResource::with(state, rid, |r| match r {
|
||||||
Ok(std_file) => std_file.metadata().map_err(AnyError::from),
|
Ok(std_file) => std_file.metadata().map_err(AnyError::from),
|
||||||
Err(_) => Err(type_error("cannot stat this type of resource".to_string())),
|
Err(_) => Err(type_error("cannot stat this type of resource".to_string())),
|
||||||
|
@ -351,7 +350,6 @@ async fn op_fstat_async(
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_zero_copy: Option<ZeroCopyBuf>,
|
_zero_copy: Option<ZeroCopyBuf>,
|
||||||
) -> Result<FsStat, AnyError> {
|
) -> Result<FsStat, AnyError> {
|
||||||
super::check_unstable2(&state, "Deno.fstat");
|
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.resource_table
|
.resource_table
|
||||||
|
|
Loading…
Reference in a new issue