mirror of
https://github.com/denoland/deno.git
synced 2025-10-02 23:24:37 +00:00
feat: URL support in Deno filesystem methods (#5990)
This commit is contained in:
parent
813210d433
commit
818a801092
28 changed files with 741 additions and 66 deletions
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "../dispatch_json.ts";
|
||||
import { build } from "../../build.ts";
|
||||
import { pathFromURL } from "../../util.ts";
|
||||
|
||||
export interface FileInfo {
|
||||
size: number;
|
||||
|
@ -65,7 +66,8 @@ export function parseFileInfo(response: StatResponse): FileInfo {
|
|||
};
|
||||
}
|
||||
|
||||
export async function lstat(path: string): Promise<FileInfo> {
|
||||
export async function lstat(path: string | URL): Promise<FileInfo> {
|
||||
path = pathFromURL(path);
|
||||
const res = (await sendAsync("op_stat", {
|
||||
path,
|
||||
lstat: true,
|
||||
|
@ -73,7 +75,8 @@ export async function lstat(path: string): Promise<FileInfo> {
|
|||
return parseFileInfo(res);
|
||||
}
|
||||
|
||||
export function lstatSync(path: string): FileInfo {
|
||||
export function lstatSync(path: string | URL): FileInfo {
|
||||
path = pathFromURL(path);
|
||||
const res = sendSync("op_stat", {
|
||||
path,
|
||||
lstat: true,
|
||||
|
@ -81,7 +84,8 @@ export function lstatSync(path: string): FileInfo {
|
|||
return parseFileInfo(res);
|
||||
}
|
||||
|
||||
export async function stat(path: string): Promise<FileInfo> {
|
||||
export async function stat(path: string | URL): Promise<FileInfo> {
|
||||
path = pathFromURL(path);
|
||||
const res = (await sendAsync("op_stat", {
|
||||
path,
|
||||
lstat: false,
|
||||
|
@ -89,7 +93,8 @@ export async function stat(path: string): Promise<FileInfo> {
|
|||
return parseFileInfo(res);
|
||||
}
|
||||
|
||||
export function statSync(path: string): FileInfo {
|
||||
export function statSync(path: string | URL): FileInfo {
|
||||
path = pathFromURL(path);
|
||||
const res = sendSync("op_stat", {
|
||||
path,
|
||||
lstat: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue