summaryrefslogtreecommitdiff
path: root/cli/js/ops/fs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/ops/fs')
-rw-r--r--cli/js/ops/fs/chmod.ts12
-rw-r--r--cli/js/ops/fs/chown.ts20
-rw-r--r--cli/js/ops/fs/copy_file.ts24
-rw-r--r--cli/js/ops/fs/dir.ts11
-rw-r--r--cli/js/ops/fs/link.ts11
-rw-r--r--cli/js/ops/fs/make_temp.ts25
-rw-r--r--cli/js/ops/fs/mkdir.ts38
-rw-r--r--cli/js/ops/fs/open.ts31
-rw-r--r--cli/js/ops/fs/read_dir.ts34
-rw-r--r--cli/js/ops/fs/read_link.ts11
-rw-r--r--cli/js/ops/fs/real_path.ts11
-rw-r--r--cli/js/ops/fs/remove.ts28
-rw-r--r--cli/js/ops/fs/rename.ts11
-rw-r--r--cli/js/ops/fs/seek.ts20
-rw-r--r--cli/js/ops/fs/stat.ts108
-rw-r--r--cli/js/ops/fs/symlink.ts23
-rw-r--r--cli/js/ops/fs/sync.ts19
-rw-r--r--cli/js/ops/fs/truncate.ts27
-rw-r--r--cli/js/ops/fs/umask.ts7
-rw-r--r--cli/js/ops/fs/utime.ts33
20 files changed, 0 insertions, 504 deletions
diff --git a/cli/js/ops/fs/chmod.ts b/cli/js/ops/fs/chmod.ts
deleted file mode 100644
index a2236935b..000000000
--- a/cli/js/ops/fs/chmod.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import { pathFromURL } from "../../util.ts";
-
-export function chmodSync(path: string | URL, mode: number): void {
- sendSync("op_chmod", { path: pathFromURL(path), mode });
-}
-
-export async function chmod(path: string | URL, mode: number): Promise<void> {
- await sendAsync("op_chmod", { path: pathFromURL(path), mode });
-}
diff --git a/cli/js/ops/fs/chown.ts b/cli/js/ops/fs/chown.ts
deleted file mode 100644
index 054b61f6c..000000000
--- a/cli/js/ops/fs/chown.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import { pathFromURL } from "../../util.ts";
-
-export function chownSync(
- path: string | URL,
- uid: number | null,
- gid: number | null,
-): void {
- sendSync("op_chown", { path: pathFromURL(path), uid, gid });
-}
-
-export async function chown(
- path: string | URL,
- uid: number | null,
- gid: number | null,
-): Promise<void> {
- await sendAsync("op_chown", { path: pathFromURL(path), uid, gid });
-}
diff --git a/cli/js/ops/fs/copy_file.ts b/cli/js/ops/fs/copy_file.ts
deleted file mode 100644
index d2d2d5688..000000000
--- a/cli/js/ops/fs/copy_file.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import { pathFromURL } from "../../util.ts";
-
-export function copyFileSync(
- fromPath: string | URL,
- toPath: string | URL,
-): void {
- sendSync("op_copy_file", {
- from: pathFromURL(fromPath),
- to: pathFromURL(toPath),
- });
-}
-
-export async function copyFile(
- fromPath: string | URL,
- toPath: string | URL,
-): Promise<void> {
- await sendAsync("op_copy_file", {
- from: pathFromURL(fromPath),
- to: pathFromURL(toPath),
- });
-}
diff --git a/cli/js/ops/fs/dir.ts b/cli/js/ops/fs/dir.ts
deleted file mode 100644
index dbf468c62..000000000
--- a/cli/js/ops/fs/dir.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "../dispatch_json.ts";
-
-export function cwd(): string {
- return sendSync("op_cwd");
-}
-
-export function chdir(directory: string): void {
- sendSync("op_chdir", { directory });
-}
diff --git a/cli/js/ops/fs/link.ts b/cli/js/ops/fs/link.ts
deleted file mode 100644
index 05ff358ef..000000000
--- a/cli/js/ops/fs/link.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export function linkSync(oldpath: string, newpath: string): void {
- sendSync("op_link", { oldpath, newpath });
-}
-
-export async function link(oldpath: string, newpath: string): Promise<void> {
- await sendAsync("op_link", { oldpath, newpath });
-}
diff --git a/cli/js/ops/fs/make_temp.ts b/cli/js/ops/fs/make_temp.ts
deleted file mode 100644
index 3996744d1..000000000
--- a/cli/js/ops/fs/make_temp.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export interface MakeTempOptions {
- dir?: string;
- prefix?: string;
- suffix?: string;
-}
-
-export function makeTempDirSync(options: MakeTempOptions = {}): string {
- return sendSync("op_make_temp_dir", options);
-}
-
-export function makeTempDir(options: MakeTempOptions = {}): Promise<string> {
- return sendAsync("op_make_temp_dir", options);
-}
-
-export function makeTempFileSync(options: MakeTempOptions = {}): string {
- return sendSync("op_make_temp_file", options);
-}
-
-export function makeTempFile(options: MakeTempOptions = {}): Promise<string> {
- return sendAsync("op_make_temp_file", options);
-}
diff --git a/cli/js/ops/fs/mkdir.ts b/cli/js/ops/fs/mkdir.ts
deleted file mode 100644
index 790b2ad05..000000000
--- a/cli/js/ops/fs/mkdir.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export interface MkdirOptions {
- recursive?: boolean;
- mode?: number;
-}
-
-interface MkdirArgs {
- path: string;
- recursive: boolean;
- mode?: number;
-}
-
-function mkdirArgs(path: string, options?: MkdirOptions): MkdirArgs {
- const args: MkdirArgs = { path, recursive: false };
- if (options != null) {
- if (typeof options.recursive == "boolean") {
- args.recursive = options.recursive;
- }
- if (options.mode) {
- args.mode = options.mode;
- }
- }
- return args;
-}
-
-export function mkdirSync(path: string, options?: MkdirOptions): void {
- sendSync("op_mkdir", mkdirArgs(path, options));
-}
-
-export async function mkdir(
- path: string,
- options?: MkdirOptions,
-): Promise<void> {
- await sendAsync("op_mkdir", mkdirArgs(path, options));
-}
diff --git a/cli/js/ops/fs/open.ts b/cli/js/ops/fs/open.ts
deleted file mode 100644
index f2cad5988..000000000
--- a/cli/js/ops/fs/open.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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;
- write?: boolean;
- append?: boolean;
- truncate?: boolean;
- create?: boolean;
- createNew?: boolean;
- /** Permissions to use if creating the file (defaults to `0o666`, before
- * the process's umask).
- * It's an error to specify mode without also setting create or createNew to `true`.
- * Ignored on Windows. */
- mode?: number;
-}
-
-export function openSync(path: string | URL, options: OpenOptions): number {
- const mode: number | undefined = options?.mode;
- return sendSync("op_open", { path: pathFromURL(path), options, mode });
-}
-
-export function open(
- path: string | URL,
- options: OpenOptions,
-): Promise<number> {
- const mode: number | undefined = options?.mode;
- return sendAsync("op_open", { path: pathFromURL(path), options, mode });
-}
diff --git a/cli/js/ops/fs/read_dir.ts b/cli/js/ops/fs/read_dir.ts
deleted file mode 100644
index 6ffe6116e..000000000
--- a/cli/js/ops/fs/read_dir.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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 DirEntry {
- name: string;
- isFile: boolean;
- isDirectory: boolean;
- isSymlink: boolean;
-}
-
-interface ReadDirResponse {
- entries: DirEntry[];
-}
-
-function res(response: ReadDirResponse): DirEntry[] {
- return response.entries;
-}
-
-export function readDirSync(path: string | URL): Iterable<DirEntry> {
- return res(sendSync("op_read_dir", { path: pathFromURL(path) }))[
- Symbol.iterator
- ]();
-}
-
-export function readDir(path: string | URL): AsyncIterable<DirEntry> {
- const array = sendAsync("op_read_dir", { path: pathFromURL(path) }).then(res);
- return {
- async *[Symbol.asyncIterator](): AsyncIterableIterator<DirEntry> {
- yield* await array;
- },
- };
-}
diff --git a/cli/js/ops/fs/read_link.ts b/cli/js/ops/fs/read_link.ts
deleted file mode 100644
index 33fef7e36..000000000
--- a/cli/js/ops/fs/read_link.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export function readLinkSync(path: string): string {
- return sendSync("op_read_link", { path });
-}
-
-export function readLink(path: string): Promise<string> {
- return sendAsync("op_read_link", { path });
-}
diff --git a/cli/js/ops/fs/real_path.ts b/cli/js/ops/fs/real_path.ts
deleted file mode 100644
index c424d99bc..000000000
--- a/cli/js/ops/fs/real_path.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export function realPathSync(path: string): string {
- return sendSync("op_realpath", { path });
-}
-
-export function realPath(path: string): Promise<string> {
- return sendAsync("op_realpath", { path });
-}
diff --git a/cli/js/ops/fs/remove.ts b/cli/js/ops/fs/remove.ts
deleted file mode 100644
index 24e23986c..000000000
--- a/cli/js/ops/fs/remove.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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 RemoveOptions {
- recursive?: boolean;
-}
-
-export function removeSync(
- path: string | URL,
- options: RemoveOptions = {},
-): void {
- sendSync("op_remove", {
- path: pathFromURL(path),
- recursive: !!options.recursive,
- });
-}
-
-export async function remove(
- path: string | URL,
- options: RemoveOptions = {},
-): Promise<void> {
- await sendAsync("op_remove", {
- path: pathFromURL(path),
- recursive: !!options.recursive,
- });
-}
diff --git a/cli/js/ops/fs/rename.ts b/cli/js/ops/fs/rename.ts
deleted file mode 100644
index f0789d3eb..000000000
--- a/cli/js/ops/fs/rename.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export function renameSync(oldpath: string, newpath: string): void {
- sendSync("op_rename", { oldpath, newpath });
-}
-
-export async function rename(oldpath: string, newpath: string): Promise<void> {
- await sendAsync("op_rename", { oldpath, newpath });
-}
diff --git a/cli/js/ops/fs/seek.ts b/cli/js/ops/fs/seek.ts
deleted file mode 100644
index 4f97514ed..000000000
--- a/cli/js/ops/fs/seek.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import type { SeekMode } from "../../io.ts";
-
-export function seekSync(
- rid: number,
- offset: number,
- whence: SeekMode,
-): number {
- return sendSync("op_seek", { rid, offset, whence });
-}
-
-export function seek(
- rid: number,
- offset: number,
- whence: SeekMode,
-): Promise<number> {
- return sendAsync("op_seek", { rid, offset, whence });
-}
diff --git a/cli/js/ops/fs/stat.ts b/cli/js/ops/fs/stat.ts
deleted file mode 100644
index f444190fd..000000000
--- a/cli/js/ops/fs/stat.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-// 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;
- mtime: Date | null;
- atime: Date | null;
- birthtime: Date | null;
- dev: number | null;
- ino: number | null;
- mode: number | null;
- nlink: number | null;
- uid: number | null;
- gid: number | null;
- rdev: number | null;
- blksize: number | null;
- blocks: number | null;
- isFile: boolean;
- isDirectory: boolean;
- isSymlink: boolean;
-}
-
-export interface StatResponse {
- isFile: boolean;
- isDirectory: boolean;
- isSymlink: boolean;
- size: number;
- mtime: number | null;
- atime: number | null;
- birthtime: number | null;
- // Unix only members
- dev: number;
- ino: number;
- mode: number;
- nlink: number;
- uid: number;
- gid: number;
- rdev: number;
- blksize: number;
- blocks: number;
-}
-
-// @internal
-export function parseFileInfo(response: StatResponse): FileInfo {
- const unix = build.os === "darwin" || build.os === "linux";
- return {
- isFile: response.isFile,
- isDirectory: response.isDirectory,
- isSymlink: response.isSymlink,
- size: response.size,
- mtime: response.mtime != null ? new Date(response.mtime) : null,
- atime: response.atime != null ? new Date(response.atime) : null,
- birthtime: response.birthtime != null ? new Date(response.birthtime) : null,
- // Only non-null if on Unix
- dev: unix ? response.dev : null,
- ino: unix ? response.ino : null,
- mode: unix ? response.mode : null,
- nlink: unix ? response.nlink : null,
- uid: unix ? response.uid : null,
- gid: unix ? response.gid : null,
- rdev: unix ? response.rdev : null,
- blksize: unix ? response.blksize : null,
- blocks: unix ? response.blocks : null,
- };
-}
-
-export function fstatSync(rid: number): FileInfo {
- return parseFileInfo(sendSync("op_fstat", { rid }));
-}
-
-export async function fstat(rid: number): Promise<FileInfo> {
- return parseFileInfo(await sendAsync("op_fstat", { rid }));
-}
-
-export async function lstat(path: string | URL): Promise<FileInfo> {
- const res = await sendAsync("op_stat", {
- path: pathFromURL(path),
- lstat: true,
- });
- return parseFileInfo(res);
-}
-
-export function lstatSync(path: string | URL): FileInfo {
- const res = sendSync("op_stat", {
- path: pathFromURL(path),
- lstat: true,
- });
- return parseFileInfo(res);
-}
-
-export async function stat(path: string | URL): Promise<FileInfo> {
- const res = await sendAsync("op_stat", {
- path: pathFromURL(path),
- lstat: false,
- });
- return parseFileInfo(res);
-}
-
-export function statSync(path: string | URL): FileInfo {
- const res = sendSync("op_stat", {
- path: pathFromURL(path),
- lstat: false,
- });
- return parseFileInfo(res);
-}
diff --git a/cli/js/ops/fs/symlink.ts b/cli/js/ops/fs/symlink.ts
deleted file mode 100644
index d96e05f24..000000000
--- a/cli/js/ops/fs/symlink.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export interface SymlinkOptions {
- type: "file" | "dir";
-}
-
-export function symlinkSync(
- oldpath: string,
- newpath: string,
- options?: SymlinkOptions,
-): void {
- sendSync("op_symlink", { oldpath, newpath, options });
-}
-
-export async function symlink(
- oldpath: string,
- newpath: string,
- options?: SymlinkOptions,
-): Promise<void> {
- await sendAsync("op_symlink", { oldpath, newpath, options });
-}
diff --git a/cli/js/ops/fs/sync.ts b/cli/js/ops/fs/sync.ts
deleted file mode 100644
index 7f208b8bd..000000000
--- a/cli/js/ops/fs/sync.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export function fdatasyncSync(rid: number): void {
- sendSync("op_fdatasync", { rid });
-}
-
-export async function fdatasync(rid: number): Promise<void> {
- await sendAsync("op_fdatasync", { rid });
-}
-
-export function fsyncSync(rid: number): void {
- sendSync("op_fsync", { rid });
-}
-
-export async function fsync(rid: number): Promise<void> {
- await sendAsync("op_fsync", { rid });
-}
diff --git a/cli/js/ops/fs/truncate.ts b/cli/js/ops/fs/truncate.ts
deleted file mode 100644
index d18e5d9d9..000000000
--- a/cli/js/ops/fs/truncate.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-function coerceLen(len?: number): number {
- if (len == null || len < 0) {
- return 0;
- }
-
- return len;
-}
-
-export function ftruncateSync(rid: number, len?: number): void {
- sendSync("op_ftruncate", { rid, len: coerceLen(len) });
-}
-
-export async function ftruncate(rid: number, len?: number): Promise<void> {
- await sendAsync("op_ftruncate", { rid, len: coerceLen(len) });
-}
-
-export function truncateSync(path: string, len?: number): void {
- sendSync("op_truncate", { path, len: coerceLen(len) });
-}
-
-export async function truncate(path: string, len?: number): Promise<void> {
- await sendAsync("op_truncate", { path, len: coerceLen(len) });
-}
diff --git a/cli/js/ops/fs/umask.ts b/cli/js/ops/fs/umask.ts
deleted file mode 100644
index fbc94091e..000000000
--- a/cli/js/ops/fs/umask.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "../dispatch_json.ts";
-
-export function umask(mask?: number): number {
- return sendSync("op_umask", { mask });
-}
diff --git a/cli/js/ops/fs/utime.ts b/cli/js/ops/fs/utime.ts
deleted file mode 100644
index bbc023ae9..000000000
--- a/cli/js/ops/fs/utime.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-function toSecondsFromEpoch(v: number | Date): number {
- return v instanceof Date ? Math.trunc(v.valueOf() / 1000) : v;
-}
-
-export function utimeSync(
- path: string,
- atime: number | Date,
- mtime: number | Date,
-): void {
- sendSync("op_utime", {
- path,
- // TODO(ry) split atime, mtime into [seconds, nanoseconds] tuple
- atime: toSecondsFromEpoch(atime),
- mtime: toSecondsFromEpoch(mtime),
- });
-}
-
-export async function utime(
- path: string,
- atime: number | Date,
- mtime: number | Date,
-): Promise<void> {
- await sendAsync("op_utime", {
- path,
- // TODO(ry) split atime, mtime into [seconds, nanoseconds] tuple
- atime: toSecondsFromEpoch(atime),
- mtime: toSecondsFromEpoch(mtime),
- });
-}