Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/io.js

Issue 29531696: Issue 5568 - Improve string handling by splitting read strings into only ASCII and non-ASCII strings (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: address comments Created Aug. 31, 2017, 1:20 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/FileSystemJsObject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 };
OLDNEW
« no previous file with comments | « no previous file | src/FileSystemJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld