UNPKG

filefive

Version:

SFTP/FTP/Amazon S3 client and dual-panel file manager for macOS and Linux

69 lines (68 loc) 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ATTRIBUTES = void 0; const promises_1 = require("node:fs/promises"); const posix_1 = require("node:path/posix"); const FileSystem_1 = require("../FileSystem"); const Local_1 = require("../Local"); const types_1 = require("../types"); exports.ATTRIBUTES = [ { name: "name", type: FileSystem_1.FileAttributeType.String, title: "Name" }, { name: "size", type: FileSystem_1.FileAttributeType.Number, title: "Size" }, { name: "modified", type: FileSystem_1.FileAttributeType.Date, title: "Last Modified" } ]; class Local extends FileSystem_1.FileSystem { open() { return Promise.resolve(types_1.LocalFileSystemID); } opened() { return true; } close() { } pwd() { return Promise.resolve((0, Local_1.pwd)()); } ls(dir) { return Promise.resolve((0, Local_1.list)(dir)); } async get(fromRemote, toLocal) { await (0, Local_1.copy)(fromRemote, toLocal, true); } async put(fromLocal, toRemote) { await (0, Local_1.copy)(fromLocal, toRemote); } async rm(path, recursive) { return (0, Local_1.del)(path); } async mkdir(path) { await (0, Local_1.mkDirRecursive)(path); } async rename(from, to) { await (0, Local_1.move)(from, to); } async mv(from, to) { try { await (0, Local_1.del)(to); } catch (e) { } await (0, Local_1.mkDirRecursive)((0, posix_1.dirname)(to)); await (0, Local_1.move)(from, to); } async cp(from, to, recursive) { await (0, promises_1.cp)((0, Local_1.osify)(from), (0, Local_1.osify)(to), { recursive, force: true }); } async write(path, data) { return (0, Local_1.write)(path, data); } } exports.default = Local;