aboutsummaryrefslogtreecommitdiff
path: root/js/io/system/chromeapi.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/system/chromeapi.js')
-rw-r--r--js/io/system/chromeapi.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/js/io/system/chromeapi.js b/js/io/system/chromeapi.js
index fc93b22a..c19a7d3b 100644
--- a/js/io/system/chromeapi.js
+++ b/js/io/system/chromeapi.js
@@ -71,7 +71,7 @@ exports.ChromeApi = Montage.create(Object.prototype, {
71 // 71 //
72 f.createWriter(function(writer) { 72 f.createWriter(function(writer) {
73 // 73 //
74 var b, mime, type = filePath.split('.'); 74 var mime, blob = new window.WebKitBlobBuilder, type = filePath.split('.');
75 type = type[type.length-1]; 75 type = type[type.length-1];
76 switch (type) { 76 switch (type) {
77 case 'bmp': 77 case 'bmp':
@@ -112,9 +112,8 @@ exports.ChromeApi = Montage.create(Object.prototype, {
112 break; 112 break;
113 } 113 }
114 // 114 //
115 b = new window.WebKitBlobBuilder; 115 blob.append(content);
116 b.append(content); 116 writer.write(blob.getBlob(mime));
117 writer.write(b.getBlob(mime));
118 // 117 //
119 if (callback) callback(true); 118 if (callback) callback(true);
120 }, function (e) {if (callback) callback(false)}); 119 }, function (e) {if (callback) callback(false)});
@@ -137,7 +136,19 @@ exports.ChromeApi = Montage.create(Object.prototype, {
137 // 136 //
138 fileContent: { 137 fileContent: {
139 enumerable: true, 138 enumerable: true,
140 value: function() { 139 value: function(filePath, callback) {
140 //
141 this.fileSystem.root.getFile(filePath, {}, function(f) {
142 f.file(function(file) {
143 var reader = new FileReader();
144 reader.onloadend = function(e) {
145 if (callback) {
146 callback({content: this.result, data: file, file: f, url: f.toURL()});
147 }
148 };
149 reader.readAsText(file);
150 }, function (e) {if (callback) callback(false)});
151 }, function (e) {if (callback) callback(false)});
141 } 152 }
142 }, 153 },
143 //////////////////////////////////////////////////////////////////// 154 ////////////////////////////////////////////////////////////////////