"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATTRIBUTES = void 0;
const promises_1 = require("node:fs/promises");
const node_path_1 = require("node:path");
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, promises_1.mkdir)(path, { recursive: true });
    }
    async rename(from, to) {
        await (0, promises_1.rename)(from, to);
    }
    async mv(from, to) {
        try {
            await (0, Local_1.del)(to);
        }
        catch (e) { }
        await (0, promises_1.mkdir)((0, node_path_1.dirname)(to), { recursive: true });
        await (0, promises_1.rename)(from, to);
    }
    async cp(from, to, recursive) {
        await (0, promises_1.cp)(from, to, { recursive, force: true });
    }
    async write(path, data) {
        await (0, promises_1.writeFile)(path, data);
    }
}
exports.default = Local;
