Skip to content

Commit

Permalink
Fixed gkFileUtils functionality for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
angelbruni committed Nov 1, 2024
1 parent 2d1bb91 commit 765383c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Profile Folder/chrome/JS/modules/GeckiumFileUtils.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class gkFileUtils {
static create(type, newFilePath) {
try {
let file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
newFilePath = Services.io.newURI(`file://${filePath.replace(/\\/g, "/")}`, null, null).QueryInterface(Components.interfaces.nsIFileURL).file.path;
file.initWithPath(newFilePath);
file.create(type, 0o755)
} catch (e) {
Expand All @@ -69,6 +70,7 @@ export class gkFileUtils {
*/
static delete(filePath) {
let file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
filePath = Services.io.newURI(`file://${filePath.replace(/\\/g, "/")}`, null, null).QueryInterface(Components.interfaces.nsIFileURL).file.path;
file.initWithPath(filePath);
file.remove(false);
}
Expand All @@ -81,9 +83,10 @@ export class gkFileUtils {
static showFileInDirectory(filePath) {
try {
let file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
filePath = Services.io.newURI(`file://${filePath.replace(/\\/g, "/")}`, null, null).QueryInterface(Components.interfaces.nsIFileURL).file.path;
file.initWithPath(filePath);
file.reveal();
} catch {
} catch (e) {
console.error(e);
}
}
Expand All @@ -96,9 +99,10 @@ export class gkFileUtils {
static launch(filePath) {
try {
let file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
filePath = Services.io.newURI(`file://${filePath.replace(/\\/g, "/")}`, null, null).QueryInterface(Components.interfaces.nsIFileURL).file.path;
file.initWithPath(filePath);
file.launch();
} catch {
} catch (e) {
console.error(e);
}
}
Expand Down

0 comments on commit 765383c

Please sign in to comment.