mirror of
https://github.com/denoland/deno.git
synced 2025-10-01 14:41:15 +00:00
Rename name/filename arguments to path (#4227)
There's a lot of variation in doc comments and internal code about whether the first parameter to file system calls is `path` or `name` or `filename`. For consistency, have made it always be `path`.
This commit is contained in:
parent
bb3d9c8280
commit
acf0958e94
10 changed files with 111 additions and 114 deletions
|
@ -8,19 +8,19 @@ function toSecondsFromEpoch(v: number | Date): number {
|
|||
/** **UNSTABLE**: needs investigation into high precision time.
|
||||
*
|
||||
* Synchronously changes the access and modification times of a file system
|
||||
* object referenced by `filename`. Given times are either in seconds
|
||||
* (Unix epoch time) or as `Date` objects.
|
||||
* object referenced by `path`. Given times are either in seconds (UNIX epoch
|
||||
* time) or as `Date` objects.
|
||||
*
|
||||
* Deno.utimeSync("myfile.txt", 1556495550, new Date());
|
||||
*
|
||||
* Requires `allow-write` permission. */
|
||||
export function utimeSync(
|
||||
filename: string,
|
||||
path: string,
|
||||
atime: number | Date,
|
||||
mtime: number | Date
|
||||
): void {
|
||||
sendSync("op_utime", {
|
||||
filename,
|
||||
path,
|
||||
// TODO(ry) split atime, mtime into [seconds, nanoseconds] tuple
|
||||
atime: toSecondsFromEpoch(atime),
|
||||
mtime: toSecondsFromEpoch(mtime)
|
||||
|
@ -30,19 +30,19 @@ export function utimeSync(
|
|||
/** **UNSTABLE**: needs investigation into high precision time.
|
||||
*
|
||||
* Changes the access and modification times of a file system object
|
||||
* referenced by `filename`. Given times are either in seconds
|
||||
* (Unix epoch time) or as `Date` objects.
|
||||
* referenced by `path`. Given times are either in seconds (UNIX epoch time)
|
||||
* or as `Date` objects.
|
||||
*
|
||||
* await Deno.utime("myfile.txt", 1556495550, new Date());
|
||||
*
|
||||
* Requires `allow-write` permission. */
|
||||
export async function utime(
|
||||
filename: string,
|
||||
path: string,
|
||||
atime: number | Date,
|
||||
mtime: number | Date
|
||||
): Promise<void> {
|
||||
await sendAsync("op_utime", {
|
||||
filename,
|
||||
path,
|
||||
// TODO(ry) split atime, mtime into [seconds, nanoseconds] tuple
|
||||
atime: toSecondsFromEpoch(atime),
|
||||
mtime: toSecondsFromEpoch(mtime)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue