mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
feat: stabilize Deno.utime() and Deno.utimeSync() (#16421)
This commit is contained in:
parent
8e3f825c92
commit
378e6a8c03
5 changed files with 42 additions and 52 deletions
|
@ -49,8 +49,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
|
||||||
"startTls",
|
"startTls",
|
||||||
"systemMemoryInfo",
|
"systemMemoryInfo",
|
||||||
"umask",
|
"umask",
|
||||||
"utime",
|
|
||||||
"utimeSync",
|
|
||||||
"spawnChild",
|
"spawnChild",
|
||||||
"Child",
|
"Child",
|
||||||
"spawn",
|
"spawn",
|
||||||
|
|
40
cli/dts/lib.deno.ns.d.ts
vendored
40
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -4026,6 +4026,46 @@ declare namespace Deno {
|
||||||
*/
|
*/
|
||||||
export function fstat(rid: number): Promise<FileInfo>;
|
export function fstat(rid: number): Promise<FileInfo>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronously changes the access (`atime`) and modification (`mtime`) times
|
||||||
|
* of a file system object referenced by `path`. Given times are either in
|
||||||
|
* seconds (UNIX epoch time) or as `Date` objects.
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* Deno.utimeSync("myfile.txt", 1556495550, new Date());
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Requires `allow-write` permission.
|
||||||
|
*
|
||||||
|
* @tags allow-write
|
||||||
|
* @category File System
|
||||||
|
*/
|
||||||
|
export function utimeSync(
|
||||||
|
path: string | URL,
|
||||||
|
atime: number | Date,
|
||||||
|
mtime: number | Date,
|
||||||
|
): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the access (`atime`) and modification (`mtime`) times of a file
|
||||||
|
* system object referenced by `path`. Given times are either in seconds
|
||||||
|
* (UNIX epoch time) or as `Date` objects.
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* await Deno.utime("myfile.txt", 1556495550, new Date());
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Requires `allow-write` permission.
|
||||||
|
*
|
||||||
|
* @tags allow-write
|
||||||
|
* @category File System
|
||||||
|
*/
|
||||||
|
export function utime(
|
||||||
|
path: string | URL,
|
||||||
|
atime: number | Date,
|
||||||
|
mtime: number | Date,
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
/** @category HTTP Server */
|
/** @category HTTP Server */
|
||||||
export interface RequestEvent {
|
export interface RequestEvent {
|
||||||
readonly request: Request;
|
readonly request: Request;
|
||||||
|
|
44
cli/dts/lib.deno.unstable.d.ts
vendored
44
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -844,50 +844,6 @@ declare namespace Deno {
|
||||||
symbols: S,
|
symbols: S,
|
||||||
): DynamicLibrary<S>;
|
): DynamicLibrary<S>;
|
||||||
|
|
||||||
/** **UNSTABLE**: needs investigation into high precision time.
|
|
||||||
*
|
|
||||||
* Synchronously changes the access (`atime`) and modification (`mtime`) times
|
|
||||||
* of a file system object referenced by `path`. Given times are either in
|
|
||||||
* seconds (UNIX epoch time) or as `Date` objects.
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* Deno.utimeSync("myfile.txt", 1556495550, new Date());
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Requires `allow-write` permission.
|
|
||||||
* Needs investigation into high precision time.
|
|
||||||
*
|
|
||||||
* @tags allow-write
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
export function utimeSync(
|
|
||||||
path: string | URL,
|
|
||||||
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
|
|
||||||
* system object referenced by `path`. Given times are either in seconds
|
|
||||||
* (UNIX epoch time) or as `Date` objects.
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* await Deno.utime("myfile.txt", 1556495550, new Date());
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Requires `allow-write` permission.
|
|
||||||
* Needs investigation into high precision time.
|
|
||||||
*
|
|
||||||
* @tags allow-write
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
export function utime(
|
|
||||||
path: string | URL,
|
|
||||||
atime: number | Date,
|
|
||||||
mtime: number | Date,
|
|
||||||
): Promise<void>;
|
|
||||||
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted.
|
/** **UNSTABLE**: New API, yet to be vetted.
|
||||||
*
|
*
|
||||||
* @category Sub Process
|
* @category Sub Process
|
||||||
|
|
|
@ -112,6 +112,8 @@
|
||||||
serveHttp: __bootstrap.http.serveHttp,
|
serveHttp: __bootstrap.http.serveHttp,
|
||||||
resolveDns: __bootstrap.net.resolveDns,
|
resolveDns: __bootstrap.net.resolveDns,
|
||||||
upgradeWebSocket: __bootstrap.http.upgradeWebSocket,
|
upgradeWebSocket: __bootstrap.http.upgradeWebSocket,
|
||||||
|
utime: __bootstrap.fs.utime,
|
||||||
|
utimeSync: __bootstrap.fs.utimeSync,
|
||||||
kill: __bootstrap.process.kill,
|
kill: __bootstrap.process.kill,
|
||||||
addSignalListener: __bootstrap.signals.addSignalListener,
|
addSignalListener: __bootstrap.signals.addSignalListener,
|
||||||
removeSignalListener: __bootstrap.signals.removeSignalListener,
|
removeSignalListener: __bootstrap.signals.removeSignalListener,
|
||||||
|
@ -133,8 +135,6 @@
|
||||||
listenDatagram: __bootstrap.netUnstable.listenDatagram,
|
listenDatagram: __bootstrap.netUnstable.listenDatagram,
|
||||||
Listener: __bootstrap.netUnstable.Listener,
|
Listener: __bootstrap.netUnstable.Listener,
|
||||||
umask: __bootstrap.fs.umask,
|
umask: __bootstrap.fs.umask,
|
||||||
utime: __bootstrap.fs.utime,
|
|
||||||
utimeSync: __bootstrap.fs.utimeSync,
|
|
||||||
HttpClient: __bootstrap.fetch.HttpClient,
|
HttpClient: __bootstrap.fetch.HttpClient,
|
||||||
createHttpClient: __bootstrap.fetch.createHttpClient,
|
createHttpClient: __bootstrap.fetch.createHttpClient,
|
||||||
http: __bootstrap.http,
|
http: __bootstrap.http,
|
||||||
|
|
|
@ -1955,8 +1955,6 @@ fn op_utime_sync(
|
||||||
mtime_secs: i64,
|
mtime_secs: i64,
|
||||||
mtime_nanos: u32,
|
mtime_nanos: u32,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
super::check_unstable(state, "Deno.utime");
|
|
||||||
|
|
||||||
let path = PathBuf::from(&path);
|
let path = PathBuf::from(&path);
|
||||||
let atime = filetime::FileTime::from_unix_time(atime_secs, atime_nanos);
|
let atime = filetime::FileTime::from_unix_time(atime_secs, atime_nanos);
|
||||||
let mtime = filetime::FileTime::from_unix_time(mtime_secs, mtime_nanos);
|
let mtime = filetime::FileTime::from_unix_time(mtime_secs, mtime_nanos);
|
||||||
|
@ -1980,8 +1978,6 @@ async fn op_utime_async(
|
||||||
mtime_secs: i64,
|
mtime_secs: i64,
|
||||||
mtime_nanos: u32,
|
mtime_nanos: u32,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
super::check_unstable(&state.borrow(), "Deno.utime");
|
|
||||||
|
|
||||||
let path = PathBuf::from(&path);
|
let path = PathBuf::from(&path);
|
||||||
let atime = filetime::FileTime::from_unix_time(atime_secs, atime_nanos);
|
let atime = filetime::FileTime::from_unix_time(atime_secs, atime_nanos);
|
||||||
let mtime = filetime::FileTime::from_unix_time(mtime_secs, mtime_nanos);
|
let mtime = filetime::FileTime::from_unix_time(mtime_secs, mtime_nanos);
|
||||||
|
|
Loading…
Reference in a new issue