1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -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:
Casper Beyer 2021-04-12 17:27:38 +08:00 committed by GitHub
parent bf99039ea9
commit 875ac73f1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 28 deletions

View file

@ -48,8 +48,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"createHttpClient",
"emit",
"formatDiagnostics",
"fstat",
"fstatSync",
"futime",
"futimeSync",
"hostname",

View file

@ -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>;
}

View file

@ -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.
*/

View file

@ -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,

View file

@ -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