OLD | NEW |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 29 matching lines...) Expand all Loading... |
40 }); | 40 }); |
41 }); | 41 }); |
42 }; | 42 }; |
43 | 43 |
44 exports.IO = | 44 exports.IO = |
45 { | 45 { |
46 lineBreak: "\n", | 46 lineBreak: "\n", |
47 | 47 |
48 readFromFile(fileName, listener) | 48 readFromFile(fileName, listener) |
49 { | 49 { |
50 return readFileAsync(fileName).then((result) => | 50 return new Promise((resolve, reject) => |
51 { | 51 { |
52 let lines = result.content.split(/[\r\n]+/); | 52 _fileSystem.readFromFile(fileName, listener, (error) => { |
53 for (let line of lines) | 53 if (error) |
54 listener(line); | 54 return reject(error); |
| 55 resolve(); |
| 56 }); |
55 }); | 57 }); |
56 }, | 58 }, |
57 | 59 |
58 writeToFile(fileName, generator) | 60 writeToFile(fileName, generator) |
59 { | 61 { |
60 let content = Array.from(generator).join(this.lineBreak) + this.lineBreak; | 62 let content = Array.from(generator).join(this.lineBreak) + this.lineBreak; |
61 return writeFileAsync(fileName, content); | 63 return writeFileAsync(fileName, content); |
62 }, | 64 }, |
63 | 65 |
64 copyFile(fromFileName, toFileName) | 66 copyFile(fromFileName, toFileName) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 { | 100 { |
99 _fileSystem.stat(fileName, (result) => | 101 _fileSystem.stat(fileName, (result) => |
100 { | 102 { |
101 if (result.error) | 103 if (result.error) |
102 return reject(result.error); | 104 return reject(result.error); |
103 resolve(result); | 105 resolve(result); |
104 }); | 106 }); |
105 }); | 107 }); |
106 } | 108 } |
107 }; | 109 }; |
OLD | NEW |