feat: URL support in Deno filesystem methods (#5990)

This commit is contained in:
River 2020-06-12 02:36:20 +10:00 committed by GitHub
parent 813210d433
commit 818a801092
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 741 additions and 66 deletions

View file

@ -1,5 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "../dispatch_json.ts";
import { pathFromURL } from "../../util.ts";
export interface OpenOptions {
read?: boolean;
@ -15,13 +16,18 @@ export interface OpenOptions {
mode?: number;
}
export function openSync(path: string, options: OpenOptions): number {
export function openSync(path: string | URL, options: OpenOptions): number {
const mode: number | undefined = options?.mode;
path = pathFromURL(path);
return sendSync("op_open", { path, options, mode });
}
export function open(path: string, options: OpenOptions): Promise<number> {
export function open(
path: string | URL,
options: OpenOptions
): Promise<number> {
const mode: number | undefined = options?.mode;
path = pathFromURL(path);
return sendAsync("op_open", {
path,
options,