diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 06:29:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 06:29:37 +0000 |
commit | 9355e23a909a7801b3ccdf68ee05b3480be42407 (patch) | |
tree | 78220623341b88bd42d16929e2acb3e5ef52e0c8 /content/modules/io.js | |
parent | Initial commit. (diff) | |
download | tbsync-9355e23a909a7801b3ccdf68ee05b3480be42407.tar.xz tbsync-9355e23a909a7801b3ccdf68ee05b3480be42407.zip |
Adding upstream version 4.7.upstream/4.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | content/modules/io.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/content/modules/io.js b/content/modules/io.js new file mode 100644 index 0000000..a4ecbdb --- /dev/null +++ b/content/modules/io.js @@ -0,0 +1,41 @@ +/* + * This file is part of TbSync. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + + "use strict"; + +var io = { + + storageDirectory : PathUtils.join(PathUtils.profileDir, "TbSync"), + + load: async function () { + }, + + unload: async function () { + }, + + getAbsolutePath: function(filename) { + return PathUtils.join(this.storageDirectory, filename); + }, + + initFile: function (filename) { + let file = FileUtils.getFile("ProfD", ["TbSync",filename]); + //create a stream to write to that file + let foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream); + foStream.init(file, 0x02 | 0x08 | 0x20, parseInt("0666", 8), 0); // write, create, truncate + foStream.close(); + }, + + appendToFile: function (filename, data) { + let file = FileUtils.getFile("ProfD", ["TbSync",filename]); + //create a strem to write to that file + let foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream); + foStream.init(file, 0x02 | 0x08 | 0x10, parseInt("0666", 8), 0); // write, create, append + foStream.write(data, data.length); + foStream.close(); + }, +} |