mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 13:41:05 +00:00
Update file.js
This commit is contained in:
parent
f904b43777
commit
c0dc768588
13
lib/file.js
13
lib/file.js
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user