-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
80 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 51 additions & 51 deletions
102
.../browser/chrome/lib/utils/file-storage.js → ...browser/chrome/lib/utils/rules-storage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
/** | ||
* This file is part of Adguard Browser Extension (https://github.com/AdguardTeam/AdguardBrowserExtension). | ||
* | ||
* Adguard Browser Extension is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Adguard Browser Extension is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Adguard Browser Extension. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* File storage adapter | ||
*/ | ||
var FS = exports.FS = { | ||
|
||
LINE_BREAK: '\n', | ||
|
||
readFromFile: function (path, callback) { | ||
try { | ||
var value = LS.getItem(path); | ||
var lines = []; | ||
if (value) { | ||
lines = value.split(/[\r\n]+/); | ||
} | ||
callback(null, lines); | ||
} catch (ex) { | ||
callback(ex); | ||
} | ||
}, | ||
|
||
writeToFile: function (path, data, callback) { | ||
var value = data.join(FS.LINE_BREAK); | ||
try { | ||
LS.setItem(path, value); | ||
callback(); | ||
} catch (ex) { | ||
callback(ex); | ||
} | ||
}, | ||
|
||
removeFile: function (path, successCallback) { | ||
LS.removeItem(path); | ||
successCallback(); | ||
} | ||
/** | ||
* This file is part of Adguard Browser Extension (https://github.com/AdguardTeam/AdguardBrowserExtension). | ||
* | ||
* Adguard Browser Extension is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Adguard Browser Extension is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Adguard Browser Extension. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* Filter rules storage adapter | ||
*/ | ||
var RulesStorage = exports.RulesStorage = { | ||
|
||
LINE_BREAK: '\n', | ||
|
||
read: function (path, callback) { | ||
try { | ||
var value = LS.getItem(path); | ||
var lines = []; | ||
if (value) { | ||
lines = value.split(/[\r\n]+/); | ||
} | ||
callback(null, lines); | ||
} catch (ex) { | ||
callback(ex); | ||
} | ||
}, | ||
|
||
write: function (path, data, callback) { | ||
var value = data.join(RulesStorage.LINE_BREAK); | ||
try { | ||
LS.setItem(path, value); | ||
callback(); | ||
} catch (ex) { | ||
callback(ex); | ||
} | ||
}, | ||
|
||
remove: function (path, successCallback) { | ||
LS.removeItem(path); | ||
successCallback(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters