"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FSStats = void 0;
/**
 * Object contains the [fs.Stats](https://nodejs.org/api/fs.html#class-fsstats)
 * for a file. Test if this has been initialized with an `fs.Stats` object by
 * calling FSStats#isInitialized.
 *
 * Contains a number of property methods that do not require asynchronous calls.
 */
class FSStats {
    _isFSStats = true;
    _stats;
    constructor(stats) {
        if (stats) {
            this._stats = stats;
        }
    }
    static isInstance(val) {
        return val && val._isFSStats === true;
    }
    /**
     * Return a copy of this object.
     * @returns
     */
    copy() {
        return new FSStats(this._stats);
    }
    /**
     * Test if the stats have been read
     * @returns
     */
    isInitialized() {
        return this._stats ? true : false;
    }
    /**
     * Clear stats.
     * @returns
     */
    clear() {
        this._stats = undefined;
        return this;
    }
    /**
     * Does the file exist? Should be called only after stats have been read.
     * @returns
     */
    exists() {
        if (this._stats) {
            return this._stats.isDirectory() === true || this._stats.isFile() === true;
        }
        return false;
    }
    isDirectory() {
        if (this._stats) {
            return this._stats.isDirectory() === true;
        }
        return false;
    }
    isFolder() {
        return this.isDirectory();
    }
    isDir() {
        return this.isDirectory();
    }
    isFile() {
        if (this._stats) {
            return this._stats.isFile() === true;
        }
        return false;
    }
    createdAt() {
        if (this._stats) {
            return new Date(this._stats.birthtime || this._stats.mtime);
        }
    }
    modifiedAt() {
        if (this._stats) {
            return new Date(this._stats.mtime);
        }
    }
    get size() {
        return this._stats ? this._stats.size : -1;
    }
}
exports.FSStats = FSStats;
//# sourceMappingURL=fsstats.js.map