UNPKG

kura

Version:

The FileSystem API abstraction library.

51 lines 1.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AbstractEntry = void 0; const FileError_1 = require("./FileError"); const FileSystemConstants_1 = require("./FileSystemConstants"); const FileSystemUtil_1 = require("./FileSystemUtil"); class AbstractEntry { constructor(params) { this.params = params; } get filesystem() { return this.params.accessor.filesystem; } get fullPath() { return this.params.fullPath; } get name() { return this.params.name; } getMetadata(successCallback, errorCallback) { successCallback({ modificationTime: this.params.lastModified == null ? null : new Date(this.params.lastModified), size: this.params.size, }); } getParent(successCallback, errorCallback) { const parentPath = (0, FileSystemUtil_1.getParentPath)(this.fullPath); const obj = (0, FileSystemUtil_1.createFileSystemObject)(parentPath, false); successCallback(this.toDirectoryEntry(obj)); } toURL(urlCallback, errorCallback, method) { this.params.accessor .getURL(this.fullPath, method) .then((url) => urlCallback(url)) .catch((e) => { (0, FileSystemUtil_1.onError)(new FileError_1.NotReadableError(this.name, this.fullPath, e), errorCallback); }); } canCopy(parent, newName, errorCallback) { const fullPath = parent.fullPath + FileSystemConstants_1.DIR_SEPARATOR + (newName || this.name); if (this.fullPath === fullPath) { (0, FileSystemUtil_1.onError)(new FileError_1.InvalidModificationError(this.filesystem.name, this.fullPath, "A entry can't be copied into itself"), errorCallback); return false; } return true; } } exports.AbstractEntry = AbstractEntry; //# sourceMappingURL=AbstractEntry.js.map