1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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();
},
}
|