LEFT | RIGHT |
(no file at all) | |
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 lineBreak: "\n", | 44 lineBreak: "\n", |
45 | 45 |
46 resolveFilePath: function(path) | 46 resolveFilePath: function(path) |
47 { | 47 { |
48 return new FakeFile(path); | 48 return new FakeFile(path); |
49 }, | 49 }, |
50 | 50 |
51 readFromFile: function(file, listener, callback, timeLineID) | 51 readFromFile: function(file, listener, callback, timeLineID) |
52 { | 52 { |
53 // Hack to allow importing old data | |
54 if (typeof file == "string") | |
55 { | |
56 var Utils = require("utils").Utils; | |
57 Utils.runAsync(function() | |
58 { | |
59 var lines = file.split(/[\r\n]+/); | |
60 for (var i = 0; i < lines.length; i++) | |
61 listener.process(lines[i]); | |
62 listener.process(null); | |
63 callback(null); | |
64 }.bind(this)); | |
65 return; | |
66 } | |
67 | |
68 this._getFileEntry(file, false, function(fs, fileEntry) | 53 this._getFileEntry(file, false, function(fs, fileEntry) |
69 { | 54 { |
70 fileEntry.file(function(file) | 55 fileEntry.file(function(file) |
71 { | 56 { |
72 if (file.size == 0) | 57 if (file.size == 0) |
73 { | 58 { |
74 callback("File is empty"); | 59 callback("File is empty"); |
75 return; | 60 return; |
76 } | 61 } |
77 | 62 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 { | 158 { |
174 fileEntry.remove(function() | 159 fileEntry.remove(function() |
175 { | 160 { |
176 callback(null); | 161 callback(null); |
177 }, callback); | 162 }, callback); |
178 }, callback); | 163 }, callback); |
179 }, | 164 }, |
180 | 165 |
181 statFile: function(file, callback) | 166 statFile: function(file, callback) |
182 { | 167 { |
183 // Hack to allow importing old data | |
184 if (typeof file == "string") | |
185 { | |
186 var Utils = require("utils").Utils; | |
187 Utils.runAsync(callback.bind(null, null, { | |
188 exists: true, | |
189 isDirectory: false, | |
190 isFile: true, | |
191 lastModified: 0 | |
192 })); | |
193 return; | |
194 } | |
195 | |
196 // This needs to use Utils.runAsync(), otherwise FilterStorage might | 168 // This needs to use Utils.runAsync(), otherwise FilterStorage might |
197 // initialize too early - see #337. | 169 // initialize too early - see #337. |
198 require("utils").Utils.runAsync(function() { | 170 require("utils").Utils.runAsync(function() { |
199 this._getFileEntry(file, false, function(fs, fileEntry) | 171 this._getFileEntry(file, false, function(fs, fileEntry) |
200 { | 172 { |
201 fileEntry.getMetadata(function(metadata) | 173 fileEntry.getMetadata(function(metadata) |
202 { | 174 { |
203 callback(null, { | 175 callback(null, { |
204 exists: true, | 176 exists: true, |
205 isDirectory: fileEntry.isDirectory, | 177 isDirectory: fileEntry.isDirectory, |
206 isFile: fileEntry.isFile, | 178 isFile: fileEntry.isFile, |
207 lastModified: metadata.modificationTime.getTime() | 179 lastModified: metadata.modificationTime.getTime() |
208 }); | 180 }); |
209 }, callback); | 181 }, callback); |
210 }, callback); | 182 }, callback); |
211 }.bind(this)); | 183 }.bind(this)); |
212 } | 184 } |
213 }; | 185 }; |
LEFT | RIGHT |