| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 { | 46 { |
| 47 content: Array.from(data), | 47 content: Array.from(data), |
| 48 lastModified: Date.now() | 48 lastModified: Date.now() |
| 49 }, | 49 }, |
| 50 callback | 50 callback |
| 51 ); | 51 ); |
| 52 } | 52 } |
| 53 | 53 |
| 54 exports.IO = | 54 exports.IO = |
| 55 { | 55 { |
| 56 resolveFilePath: path => new FakeFile(path), | 56 resolveFilePath(path) { return new FakeFile(path); }, |
| 57 | 57 |
| 58 readFromFile: (file, listener, callback) => | 58 readFromFile(file, listener, callback) |
| 59 { | 59 { |
| 60 function onLoaded(entry) | 60 function onLoaded(entry) |
| 61 { | 61 { |
| 62 for (let line of entry.content) | 62 for (let line of entry.content) |
| 63 listener.process(line); | 63 listener.process(line); |
| 64 | 64 |
| 65 listener.process(null); | 65 listener.process(null); |
| 66 callback(null); | 66 callback(null); |
| 67 } | 67 } |
| 68 | 68 |
| 69 loadFile(file, onLoaded, callback); | 69 loadFile(file, onLoaded, callback); |
| 70 }, | 70 }, |
| 71 | 71 |
| 72 writeToFile: (file, data, callback) => | 72 writeToFile(file, data, callback) |
| 73 { | 73 { |
| 74 saveFile(file, data, callback); | 74 saveFile(file, data, callback); |
| 75 }, | 75 }, |
| 76 | 76 |
| 77 copyFile: (fromFile, toFile, callback) => | 77 copyFile(fromFile, toFile, callback) |
| 78 { | 78 { |
| 79 function onLoaded(entry) | 79 function onLoaded(entry) |
| 80 { | 80 { |
| 81 saveFile(toFile, entry.content, callback); | 81 saveFile(toFile, entry.content, callback); |
| 82 } | 82 } |
| 83 | 83 |
| 84 loadFile(fromFile, onLoaded, callback); | 84 loadFile(fromFile, onLoaded, callback); |
| 85 }, | 85 }, |
| 86 | 86 |
| 87 renameFile: (fromFile, newName, callback) => | 87 renameFile(fromFile, newName, callback) |
| 88 { | 88 { |
| 89 function onLoaded(entry) | 89 function onLoaded(entry) |
| 90 { | 90 { |
| 91 ext.storage.remove(fileToKey(fromFile), () => | 91 ext.storage.remove(fileToKey(fromFile), () => |
| 92 { | 92 { |
| 93 ext.storage.set(keyPrefix + newName, entry, callback); | 93 ext.storage.set(keyPrefix + newName, entry, callback); |
| 94 }); | 94 }); |
| 95 } | 95 } |
| 96 | 96 |
| 97 loadFile(fromFile, onLoaded, callback); | 97 loadFile(fromFile, onLoaded, callback); |
| 98 }, | 98 }, |
| 99 | 99 |
| 100 removeFile: (file, callback) => | 100 removeFile(file, callback) |
| 101 { | 101 { |
| 102 ext.storage.remove(fileToKey(file), callback); | 102 ext.storage.remove(fileToKey(file), callback); |
| 103 }, | 103 }, |
| 104 | 104 |
| 105 statFile: (file, callback) => | 105 statFile(file, callback) |
| 106 { | 106 { |
| 107 function onLoaded(entry) | 107 function onLoaded(entry) |
| 108 { | 108 { |
| 109 callback(null, { | 109 callback(null, { |
| 110 exists: true, | 110 exists: true, |
| 111 lastModified: entry.lastModified | 111 lastModified: entry.lastModified |
| 112 }); | 112 }); |
| 113 } | 113 } |
| 114 | 114 |
| 115 loadFile(file, onLoaded, callback); | 115 loadFile(file, onLoaded, callback); |
| 116 } | 116 } |
| 117 }; | 117 }; |
| LEFT | RIGHT |