Path: blob/master/lib/lowdb/adapters/TextFileSync.js
2591 views
//═══════════════════════════════════════════════════════//1//If you want to recode, reupload2//or copy the codes/script,3//pls give credit4//no credit? i will take action immediately5//© 2022 Xeon Bot Inc. Cheems Bot MD6//Thank you to Lord Buddha, Family and Myself7//════════════════════════════//8const fs = require('fs');9const path = require('path');10class TextFileSync {11constructor(filename) {12this.filename = filename;13this.tempFilename = path.join(path.dirname(filename), `.${path.basename(filename)}.tmp`);14}15read() {16let data;17try {18data = fs.readFileSync(this.filename, 'utf-8');19}20catch (e) {21if (e.code === 'ENOENT') {22return null;23}24throw e;25}26return data;27}28write(str) {29fs.writeFileSync(this.tempFilename, str);30fs.renameSync(this.tempFilename, this.filename);31}32}33module.exports = { TextFileSync };343536