FileUtils.sys.mjs (734B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 export const FileUtils = { 7 getProfileDirectory() { 8 return Services.dirsvc.get("ProfD", Ci.nsIFile); 9 }, 10 11 getFile(relativePath, baseFile) { 12 if (!baseFile) { 13 baseFile = this.getProfileDirectory(); 14 } 15 16 let file = baseFile.clone(); 17 18 if (Services.appinfo.OS === "WINNT") { 19 const winFile = file.QueryInterface(Ci.nsILocalFileWin); 20 winFile.useDOSDevicePathSyntax = true; 21 } 22 23 relativePath.split("/").forEach(function (component) { 24 if (component == "..") { 25 file = file.parent; 26 } else { 27 file.append(component); 28 } 29 }); 30 31 return file; 32 }, 33 };