OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 { | 100 { |
101 if (writer.error) | 101 if (writer.error) |
102 callback(writer.error); | 102 callback(writer.error); |
103 else | 103 else |
104 nextOperation(); | 104 nextOperation(); |
105 }.bind(this); | 105 }.bind(this); |
106 | 106 |
107 op(); | 107 op(); |
108 }.bind(this); | 108 }.bind(this); |
109 | 109 |
110 executeWriteOperation(writer.truncate.bind(writer, 0), function() | 110 var blob; |
| 111 |
| 112 try |
111 { | 113 { |
112 var blob; | 114 blob = new Blob([data.join(this.lineBreak) + this.lineBreak], {type: "
text/plain"}); |
113 try | 115 } |
114 { | 116 catch (e) |
115 blob = new Blob([data.join(this.lineBreak) + this.lineBreak], {type:
"text/plain"}); | 117 { |
116 } | 118 if (!(e instanceof TypeError)) |
117 catch (e) | 119 throw e; |
118 { | |
119 if (!(e instanceof TypeError)) | |
120 throw e; | |
121 | 120 |
122 // Blob wasn't a constructor before Chrome 20 | 121 // Blob wasn't a constructor before Chrome 20 |
123 var builder = new (window.BlobBuilder || window.WebKitBlobBuilder); | 122 var builder = new (window.BlobBuilder || window.WebKitBlobBuilder); |
124 builder.append(data.join(this.lineBreak) + this.lineBreak); | 123 builder.append(data.join(this.lineBreak) + this.lineBreak); |
125 blob = builder.getBlob("text/plain"); | 124 blob = builder.getBlob("text/plain"); |
126 } | 125 } |
127 executeWriteOperation(writer.write.bind(writer, blob), callback.bind(n
ull, null)); | 126 executeWriteOperation(writer.write.bind(writer, blob), function() |
128 }.bind(this)); | 127 { |
| 128 executeWriteOperation(writer.truncate.bind(writer, writer.position), c
allback.bind(null, null)); |
| 129 }); |
129 }.bind(this), callback); | 130 }.bind(this), callback); |
130 }.bind(this), callback); | 131 }.bind(this), callback); |
131 }, | 132 }, |
132 | 133 |
133 copyFile: function(fromFile, toFile, callback) | 134 copyFile: function(fromFile, toFile, callback) |
134 { | 135 { |
135 // Simply combine read and write operations | 136 // Simply combine read and write operations |
136 var data = []; | 137 var data = []; |
137 this.readFromFile(fromFile, { | 138 this.readFromFile(fromFile, { |
138 process: function(line) | 139 process: function(line) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 exists: true, | 198 exists: true, |
198 isDirectory: fileEntry.isDirectory, | 199 isDirectory: fileEntry.isDirectory, |
199 isFile: fileEntry.isFile, | 200 isFile: fileEntry.isFile, |
200 lastModified: metadata.modificationTime.getTime() | 201 lastModified: metadata.modificationTime.getTime() |
201 }); | 202 }); |
202 }, callback); | 203 }, callback); |
203 }, callback); | 204 }, callback); |
204 }.bind(this)); | 205 }.bind(this)); |
205 } | 206 } |
206 }; | 207 }; |
OLD | NEW |