Index: lib/io.js |
=================================================================== |
--- a/lib/io.js |
+++ b/lib/io.js |
@@ -71,32 +71,43 @@ function callLegacy(method, ...args) |
function legacyFile(fileName) |
{ |
let file = LegacyIO.resolveFilePath("adblockplus"); |
file.append(fileName); |
return file; |
} |
+function ensureDirExists(file) |
+{ |
+ if (!file.exists()) |
+ { |
+ ensureDirExists(file.parent); |
+ file.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755); |
+ } |
+} |
+ |
let fallback = { |
readFromFile(fileName, listener) |
{ |
let wrapper = { |
process(line) |
{ |
if (line !== null) |
listener(line); |
} |
}; |
return callLegacy("readFromFile", legacyFile(fileName), wrapper); |
}, |
writeToFile(fileName, data) |
{ |
- return callLegacy("writeToFile", legacyFile(fileName), data); |
+ let file = legacyFile(fileName); |
+ ensureDirExists(file.parent); |
Wladimir Palant
2017/06/01 09:16:41
For reference, this operation was originally being
|
+ return callLegacy("writeToFile", file, data); |
}, |
copyFile(fromFile, toFile) |
{ |
return callLegacy("copyFile", legacyFile(fromFile), legacyFile(toFile)); |
}, |
renameFile(fromFile, newName) |