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

Unified Diff: lib/io.js

Issue 5740786045943808: Issue 189 - Implement API changes from #117, #153, #192 in libadblockplus (Closed)
Patch Set: Created April 14, 2014, 9:14 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/init.js ('K') | « lib/init.js ('k') | lib/prefs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/io.js
===================================================================
--- a/lib/io.js
+++ b/lib/io.js
@@ -19,63 +19,55 @@ var IO = exports.IO =
{
lineBreak: "\n",
resolveFilePath: function(path)
{
return new FakeFile(_fileSystem.resolve(path));
},
- readFromFile: function(file, decode, listener, callback, timeLineID)
+ readFromFile: function(file, listener, callback, timeLineID)
{
- if ("spec" in file && /^defaults\b/.test(file.spec))
- {
- // Code attempts to read the default patterns.ini, we don't have that.
- // Make sure to execute first-run actions instead.
- callback(null);
- return;
- }
-
_fileSystem.read(file.path, function(result)
{
if (result.error)
callback(result.error);
else
{
var lines = result.content.split(/[\r\n]+/);
for (var i = 0; i < lines.length; i++)
listener.process(lines[i]);
listener.process(null);
callback(null);
}
});
},
- writeToFile: function(file, encode, data, callback, timeLineID)
+ writeToFile: function(file, data, callback, timeLineID)
{
var content = data.join(this.lineBreak) + this.lineBreak;
_fileSystem.write(file.path, content, callback);
},
copyFile: function(fromFile, toFile, callback)
{
// Simply combine read and write operations
var data = [];
- this.readFromFile(fromFile, false, {
+ this.readFromFile(fromFile, {
process: function(line)
{
if (line !== null)
data.push(line);
}
}, function(e)
{
if (e)
callback(e);
else
- this.writeToFile(toFile, false, data, callback);
+ this.writeToFile(toFile, data, callback);
}.bind(this));
},
renameFile: function(fromFile, newName, callback)
{
_fileSystem.move(fromFile.path, newName, callback);
},
« lib/init.js ('K') | « lib/init.js ('k') | lib/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld