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

Unified Diff: lib/filesystem/io.js

Issue 5442569823584256: Issue 189 - Implement API changes from #117, #153, #192 in Chrome (Closed)
Patch Set: Fixed #301 fallout as well Created April 15, 2014, 7:03 a.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
« background.js ('K') | « background.js ('k') | lib/prefs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filesystem/io.js
===================================================================
--- a/lib/filesystem/io.js
+++ b/lib/filesystem/io.js
@@ -43,48 +43,33 @@ var IO = exports.IO =
lineBreak: "\n",
resolveFilePath: function(path)
{
return new FakeFile(path);
},
- readFromFile: function(file, decode, listener, callback, timeLineID)
+ readFromFile: function(file, listener, callback, timeLineID)
{
// Hack to allow importing old data
if (typeof file == "string")
{
var Utils = require("utils").Utils;
Utils.runAsync(function()
{
var lines = file.split(/[\r\n]+/);
for (var i = 0; i < lines.length; i++)
listener.process(lines[i]);
listener.process(null);
callback(null);
}.bind(this));
return;
}
- 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.
- var Utils = require("utils").Utils;
- Utils.runAsync(function()
- {
- if (ext.storage.currentVersion)
- seenDataCorruption = true;
- delete ext.storage.currentVersion;
- callback(null);
- });
- return;
- }
-
this._getFileEntry(file, false, function(fs, fileEntry)
{
fileEntry.file(function(file)
{
var reader = new FileReader();
reader.onloadend = function()
{
if (reader.error)
@@ -98,17 +83,17 @@ var IO = exports.IO =
callback(null);
}
};
reader.readAsText(file);
}, callback);
}, callback);
},
- writeToFile: function(file, encode, data, callback, timeLineID)
+ writeToFile: function(file, data, callback, timeLineID)
{
this._getFileEntry(file, true, function(fs, fileEntry)
{
fileEntry.createWriter(function(writer)
{
var executeWriteOperation = function(op, nextOperation)
{
writer.onwriteend = function()
@@ -144,28 +129,28 @@ var IO = exports.IO =
}.bind(this), callback);
}.bind(this), 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)
{
this._getFileEntry(fromFile, false, function(fs, fileEntry)
{
fileEntry.moveTo(fs.root, newName, function()
« background.js ('K') | « background.js ('k') | lib/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld