ConceptCreator/app/storage/FileUtils.js
Sebastian Böckelmann c184c667fd
Some checks failed
E2E Testing / test (push) Failing after 1m42s
Delete Unreferenced Gamesystems
2024-03-21 08:43:28 +01:00

34 lines
1019 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileUtils = void 0;
const fs = require("fs");
const path = require("node:path");
const fs_1 = require("fs");
class FileUtils {
static listFilesInDirectory(directory) {
if (fs.lstatSync(directory).isDirectory()) {
return fs.readdirSync(directory).map(fileName => path.join(directory, fileName));
}
else {
return [];
}
}
static prepareFileForWriting(file) {
const parentDirectory = path.dirname(file);
if (!fs.existsSync(parentDirectory)) {
(0, fs_1.mkdirSync)(parentDirectory, { recursive: true });
}
}
static removeFiles(files) {
files.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
fs.rmdirSync(file);
}
else {
fs.unlinkSync(file);
}
});
}
}
exports.FileUtils = FileUtils;
//# sourceMappingURL=FileUtils.js.map