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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*global alert, app, window, runtime*/
var LocalFileSystem = {
PERSISTENT: 0,
TEMPORARY: 1
};
function FileEntry(name, fullPath) {
"use strict";
this.isFile = true;
this.isDirectory = false;
this.name = name;
this.fullPath = fullPath;
this.file = function (onsuccess, onerror) {
function File(fullPath) {
this.name = name;
this.fullPath = fullPath;
this.type = "";
this.size = -1;
this.lastModifiedDate = -1;
}
var file = new File(fullPath);
try {
onsuccess(file);
} catch (e) {
alert("Error on determining file properties: " + e);
onerror(e);
}
};
}
function FileReader() {
"use strict";
var fr = this;
this.readAsArrayBuffer = function (file) {
var path = file.fullPath.substr(7),
data = runtime.readFileSync(path, 'binary');
data = runtime.byteArrayFromString(data, "binary");
window.setTimeout(function () {
fr.onloadend({target: {result: data}});
}, 1);
};
}
var DirectoryReader;
function DirectoryEntry(name, fullPath) {
"use strict";
this.isFile = false;
this.isDirectory = true;
this.name = name;
this.fullPath = fullPath;
this.createReader = function () {
var reader = new DirectoryReader(fullPath);
return reader;
};
}
function DirectoryReader(fullPath) {
"use strict";
this.readEntries = function (onsuccess, onerror) {
window.setTimeout(function () {
var entries = [];
entries[entries.length] = new FileEntry("welcome.odt",
"welcome.odt");
entries[entries.length] = new FileEntry("Traktatenblad.odt",
"Traktatenblad.odt");
try {
onsuccess(entries);
} catch (e) {
onerror(e);
}
}, 1);
};
}
window.resolveLocalFileSystemURI = function (path, onsuccess, onerror) {
"use strict";
var p = path.lastIndexOf("/"),
name = (p === -1) ? path : path.substr(p + 1);
onsuccess(new FileEntry(name, path));
};
window.requestFileSystem = function (filesystem, id, onsuccess, onerror) {
"use strict";
var dirs = [], shared, subfolder, path;
try {
if (filesystem === LocalFileSystem.PERSISTENT) {
path = "";
onsuccess({
name: "root",
root: new DirectoryEntry("root", path)
});
} else {
onerror("not defined");
}
} catch (e) {
onerror(e);
}
};
var device = {};
|