Update file.js

This commit is contained in:
Namhyeon Go 2023-09-21 21:45:26 +09:00 committed by GitHub
parent f904b43777
commit c0dc768588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,10 +54,15 @@ function fileGet(FN) {
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
function readFile(FN, charset) { function readFile(FN, charset) {
if (typeof charset === "undefined") {
console.warn("CHARSET has not been passed. Force to UTF-8.");
charset = PipeIPC.CdoUTF_8;
}
var text = ''; var text = '';
var pipe = PipeIPC.connect("volatile"); var pipe = PipeIPC.connect("volatile");
pipe.setCharset(charset); pipe.setCharset(charset);
pipe.loadFromFile(FN); pipe.loadFromFile(FN, charset);
text += pipe.read(); text += pipe.read();
pipe.destroy(); pipe.destroy();
@ -71,11 +76,11 @@ function readFile(FN, charset) {
function writeFile(FN, content, charset) { function writeFile(FN, content, charset) {
if (typeof content === "undefined") { if (typeof content === "undefined") {
console.warn("The content parameter has not been passed. Force to empty string."); console.warn("CONTENT has not been passed. Force to empty string.");
content = ''; content = '';
} }
if (typeof charset === "undefined") { if (typeof charset === "undefined") {
console.warn("The charset parameter has not been passed. Force to UTF-8."); console.warn("CHARSET has not been passed. Force to UTF-8.");
charset = PipeIPC.CdoUTF_8; charset = PipeIPC.CdoUTF_8;
} }
@ -189,6 +194,6 @@ exports.includeFile = includeFile;
exports.appendFile = appendFile; exports.appendFile = appendFile;
exports.rotateFile = rotateFile; exports.rotateFile = rotateFile;
exports.VERSIONINFO = "File Library (file.js) version 0.2.7"; exports.VERSIONINFO = "File Library (file.js) version 0.2.8";
exports.global = global; exports.global = global;
exports.require = global.require; exports.require = global.require;