1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

feat: stabilize Deno.futime() and Deno.futimeSync() (#16415)

This commit is contained in:
Colin Ihrig 2022-10-25 14:03:05 -04:00 committed by GitHub
parent 3f22f912ec
commit ffff814540
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 48 deletions

View file

@ -37,8 +37,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"connect",
"consoleSize",
"createHttpClient",
"futime",
"futimeSync",
"kill",
"listen",
"listenDatagram",

View file

@ -3962,6 +3962,42 @@ declare namespace Deno {
*/
export function ftruncate(rid: number, len?: number): Promise<void>;
/**
* Synchronously changes the access (`atime`) and modification (`mtime`) times
* of a file stream resource referenced by `rid`. Given times are either in
* seconds (UNIX epoch time) or as `Date` objects.
*
* ```ts
* const file = Deno.openSync("file.txt", { create: true, write: true });
* Deno.futimeSync(file.rid, 1556495550, new Date());
* ```
*
* @category File System
*/
export function futimeSync(
rid: number,
atime: number | Date,
mtime: number | Date,
): void;
/**
* Changes the access (`atime`) and modification (`mtime`) times of a file
* stream resource referenced by `rid`. Given times are either in seconds
* (UNIX epoch time) or as `Date` objects.
*
* ```ts
* const file = await Deno.open("file.txt", { create: true, write: true });
* await Deno.futime(file.rid, 1556495550, new Date());
* ```
*
* @category File System
*/
export function futime(
rid: number,
atime: number | Date,
mtime: number | Date,
): Promise<void>;
/**
* Synchronously returns a `Deno.FileInfo` for the given file stream.
*

View file

@ -980,48 +980,6 @@ declare namespace Deno {
options: CreateHttpClientOptions,
): HttpClient;
/** **UNSTABLE**: New API, yet to be vetted.
*
* Synchronously changes the access (`atime`) and modification (`mtime`) times
* of a file stream resource referenced by `rid`. Given times are either in
* seconds (UNIX epoch time) or as `Date` objects.
*
* ```ts
* const file = Deno.openSync("file.txt", { create: true, write: true });
* Deno.futimeSync(file.rid, 1556495550, new Date());
* ```
*
* Needs investigation into high precision time.
*
* @category File System
*/
export function futimeSync(
rid: number,
atime: number | Date,
mtime: number | Date,
): void;
/** **UNSTABLE**: New API, yet to be vetted.
*
* Changes the access (`atime`) and modification (`mtime`) times of a file
* stream resource referenced by `rid`. Given times are either in seconds
* (UNIX epoch time) or as `Date` objects.
*
* ```ts
* const file = await Deno.open("file.txt", { create: true, write: true });
* await Deno.futime(file.rid, 1556495550, new Date());
* ```
*
* Needs investigation into high precision time.
*
* @category File System
*/
export function futime(
rid: number,
atime: number | Date,
mtime: number | Date,
): Promise<void>;
/** **UNSTABLE**: New API, yet to be vetted.
*
* A generic transport listener for message-oriented protocols.

View file

@ -55,6 +55,8 @@
truncate: __bootstrap.fs.truncate,
ftruncateSync: __bootstrap.fs.ftruncateSync,
ftruncate: __bootstrap.fs.ftruncate,
futime: __bootstrap.fs.futime,
futimeSync: __bootstrap.fs.futimeSync,
errors: __bootstrap.errors.errors,
// TODO(kt3k): Remove this export at v2
// See https://github.com/denoland/deno/issues/9294
@ -128,8 +130,6 @@
getUid: __bootstrap.os.getUid,
listenDatagram: __bootstrap.net.listenDatagram,
umask: __bootstrap.fs.umask,
futime: __bootstrap.fs.futime,
futimeSync: __bootstrap.fs.futimeSync,
utime: __bootstrap.fs.utime,
utimeSync: __bootstrap.fs.utimeSync,
HttpClient: __bootstrap.fetch.HttpClient,

View file

@ -1916,7 +1916,6 @@ fn op_futime_sync(
mtime_secs: i64,
mtime_nanos: u32,
) -> Result<(), AnyError> {
super::check_unstable(state, "Deno.futimeSync");
let atime = filetime::FileTime::from_unix_time(atime_secs, atime_nanos);
let mtime = filetime::FileTime::from_unix_time(mtime_secs, mtime_nanos);
@ -1937,7 +1936,6 @@ async fn op_futime_async(
mtime_secs: i64,
mtime_nanos: u32,
) -> Result<(), AnyError> {
super::check_unstable2(&state, "Deno.futime");
let atime = filetime::FileTime::from_unix_time(atime_secs, atime_nanos);
let mtime = filetime::FileTime::from_unix_time(mtime_secs, mtime_nanos);