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

Delta Between Two Patch Sets: lib/storage/io.js

Issue 5442569823584256: Issue 189 - Implement API changes from #117, #153, #192 in Chrome (Closed)
Left Patch Set: Created April 14, 2014, 7:31 a.m.
Right Patch Set: Fixed #301 fallout as well Created April 15, 2014, 7:03 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/prefs.js ('k') | lib/utils.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 this._setFileContents(path, data.join(this.lineBreak) + this.lineBreak, Date .now()); 70 this._setFileContents(path, data.join(this.lineBreak) + this.lineBreak, Date .now());
71 71
72 var Utils = require("utils").Utils; 72 var Utils = require("utils").Utils;
73 Utils.runAsync(callback, null, null); 73 Utils.runAsync(callback, null, null);
74 }, 74 },
75 75
76 copyFile: function(fromFile, toFile, callback) 76 copyFile: function(fromFile, toFile, callback)
77 { 77 {
78 // Simply combine read and write operations 78 // Simply combine read and write operations
79 var data = []; 79 var data = [];
80 this.readFromFile(fromFile, false, { 80 this.readFromFile(fromFile, {
81 process: function(line) 81 process: function(line)
82 { 82 {
83 if (line !== null) 83 if (line !== null)
84 data.push(line); 84 data.push(line);
85 } 85 }
86 }, function(e) 86 }, function(e)
87 { 87 {
88 if (e) 88 if (e)
89 callback(e); 89 callback(e);
90 else 90 else
91 this.writeToFile(toFile, false, data, callback); 91 this.writeToFile(toFile, data, callback);
92 }.bind(this)); 92 }.bind(this));
93 }, 93 },
94 94
95 renameFile: function(fromFile, newName, callback) 95 renameFile: function(fromFile, newName, callback)
96 { 96 {
97 var path = this._getFilePath(fromFile); 97 var path = this._getFilePath(fromFile);
98 if (!(path in ext.storage)) 98 if (!(path in ext.storage))
99 { 99 {
100 callback(new Error("File doesn't exist")) 100 callback(new Error("File doesn't exist"))
101 return; 101 return;
(...skipping 15 matching lines...) Expand all
117 { 117 {
118 var path = this._getFilePath(file); 118 var path = this._getFilePath(file);
119 callback(null, { 119 callback(null, {
120 exists: path in ext.storage, 120 exists: path in ext.storage,
121 isDirectory: false, 121 isDirectory: false,
122 isFile: true, 122 isFile: true,
123 lastModified: parseInt(ext.storage[path + "/lastModified"], 10) || 0 123 lastModified: parseInt(ext.storage[path + "/lastModified"], 10) || 0
124 }); 124 });
125 } 125 }
126 }; 126 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld