"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get ensureDirExists () {
        return ensureDirExists;
    },
    get getDatabaseFilePath () {
        return getDatabaseFilePath;
    },
    get getDatabaseFolder () {
        return getDatabaseFolder;
    },
    get getMediaPath () {
        return getMediaPath;
    },
    get packageJsonPath () {
        return packageJsonPath;
    },
    get superRootPath () {
        return superRootPath;
    }
});
const _nodefs = require("node:fs");
const _nodepath = require("node:path");
const _serverconstants = require("../server.constants");
const _envutils = require("./env.utils");
function getDatabaseFilePath() {
    const dbFile = (0, _envutils.getEnvOrDefault)(_serverconstants.AppConstants.DATABASE_FILE, _serverconstants.AppConstants.defaultDatabaseFile);
    if (dbFile === ":memory:") {
        return dbFile;
    }
    const dbFolder = getDatabaseFolder();
    return (0, _nodepath.join)(dbFolder, dbFile);
}
function getDatabaseFolder() {
    return (0, _envutils.getEnvOrDefault)(_serverconstants.AppConstants.DATABASE_PATH, (0, _nodepath.join)(superRootPath(), _serverconstants.AppConstants.defaultDatabasePath));
}
function getMediaPath() {
    return (0, _envutils.getEnvOrDefault)(_serverconstants.AppConstants.MEDIA_PATH, (0, _nodepath.join)(superRootPath(), _serverconstants.AppConstants.defaultBaseMediaPath));
}
function packageJsonPath() {
    return (0, _nodepath.join)(superRootPath(), "./package.json");
}
function ensureDirExists(dir) {
    if ((0, _nodefs.existsSync)(dir)) {
        return;
    }
    (0, _nodefs.mkdirSync)(dir, {
        recursive: true
    });
}
function superRootPath() {
    return (0, _nodepath.join)(__dirname, "../..");
}

//# sourceMappingURL=fs.utils.js.map