@ton-contests/tact-utils
Version:
Tact utilities for TON Contests plaform
29 lines (28 loc) • 842 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileSystem = void 0;
const path_1 = require("path");
const fs_1 = require("fs");
const fs_2 = require("../misc/fs");
class FileSystem {
root;
constructor(root) {
this.root = (0, path_1.normalize)(root);
if (!this.root.endsWith(path_1.sep)) {
this.root += path_1.sep;
}
}
resolve(...path) {
return (0, path_1.normalize)((0, path_1.resolve)(this.root, ...path));
}
exists(path) {
return (0, fs_1.existsSync)(path);
}
readFile(path) {
return (0, fs_1.readFileSync)(path);
}
writeFile(path, content) {
(0, fs_2.writeFileWithDirsSync)(path, typeof content === "string" ? Buffer.from(content, "utf-8") : content);
}
}
exports.FileSystem = FileSystem;