Skip to content

Commit

Permalink
feat(runtime): stabilize Deno.fstat and Deno.fstatSync (denoland#10108)
Browse files Browse the repository at this point in the history
This commit stabilizes Deno.fstat and Deno.fstatSync 
which are well known system calls and have a stable interface.
  • Loading branch information
caspervonb committed Apr 12, 2021
1 parent bf99039 commit 875ac73
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 28 deletions.
2 changes: 0 additions & 2 deletions cli/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"createHttpClient",
"emit",
"formatDiagnostics",
"fstat",
"fstatSync",
"futime",
"futimeSync",
"hostname",
Expand Down
22 changes: 22 additions & 0 deletions cli/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 0 additions & 22 deletions cli/dts/lib.deno.unstable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 2 additions & 2 deletions runtime/js/90_deno_ns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions runtime/ops/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
Expand All @@ -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
Expand Down

0 comments on commit 875ac73

Please sign in to comment.