OSX - 更改特殊路径,尤其是传送更新的文件夹 [英] OSX - Change special paths, especialy folder to which update is delivered

查看:384
本文介绍了OSX - 更改特殊路径,尤其是传送更新的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在MacOS XI中复制了所有内容 / Applications / Firefox.app / Users / noit / Desktop / custom profile.app 。除了所有文件都被作为别名复制(文件夹被复制为文件夹)。只有非别名文件是 custom profile.app/Contents/Resources/firefox.icns 中的图标,我用自定义图标覆盖了那个文件。 (好吧,准确地说,plist.info被复制,但CFBundleExecutable被更改为一个新的执行我放在MacOS文件夹,从MacOS启动Firefox的命令行参数,以确保正确的配置文件启动)

这使我可以运行一个单独的配置文件作为快捷方式。现在,如果用户在Dock中保留显示或在重新启动计算机上的Dock图标标记为上次重新打开窗口,或者用户右键单击Dock图标并显示在登录时打开,或者用户重新启动Firefox正确启动回到正确的配置文件。



    $添加的红利是服从自定义图标。 b $ b
  • 更新时,文件被写入 / Desktop / custom profile.app ,而不是 Applications / Firefox.app 。所以现在在浏览器启动时,我测试它是否第一次在更新配置文件中启动,如果是,那么我确保将新创建的文件复制回 Applications / Firefox.app 并将它们设置为我的 / Desktop / custom profile.app 中的别名。 __是否有任何方法可以改变路径,使其更新到 Applications / Firefox.app

  • 另一个问题是,特殊路径现在指向不同,例如 FileUtils.getFile('XREExeF',[])。path 现在是 / Desktop / custom profile.app/目录/ MacOS / firefox 而不是 Applications / Firefox.app /....,有没有办法让我改变这个应用程序路径?



谢谢

编辑:

以下是右侧的常规应用程序与左侧的别名复制应用程序之间的区别: .diffchecker.com / lihx3o8wrel =nofollow> https://www.diffchecker.com/lihx3o8w



共20个:

  Key Regular.app Alias.app 
`XREExeF``/Applications/Firefox.app /内容/ MacOS的/ firefox` `/ Users / noit / Desktop / Firefox - dev.app / Contents / MacOS / firefox`
`ProfLDS``/Users/noit/Library/Caches/Firefox/Profiles/jv5ijq47.Unnamed Profile 1``/ Users / noit / Library / Application Support / Firefox / Profiles / jv5ijq47.Unnamed Profile 1`
`XREAppDist`` / Applications / Firefox.app / Contents / Resources / distribution``/ Users / noit / Desktop / Firefox - dev .app / Contents / Resources / distribution`
`UpdRootD`` / Users / noit / Library / Caches / Mozilla / updates / Applications / Firefox``/ Users / noit / Library / Caches / Mozilla / updates / Users / noit / Desktop / Firefox - dev`
`DefRt``/ Applications / Firefox.app / Contents / Resources / browser / defaults``/ Users / noit / Desktop / Firefox - dev.app/Contents/Resources/browser / defaults`
`PrfDef``/ Applications / Firefox.app / Contents / Resources / defaults / pref``/ Users / noit / Desktop / Firefox - dev.app / Contents / Resources / defaults / pref`
`profDef`` /Applications/Firefox.app/Contents/Res resources / browser / defaults / profile``/ Users / noit / Desktop / Firefox - dev.app / Contents / Resources / browser / defaults / profile`
`ProfDefNoLoc` /Applications/Firefox.app/Contents/Resources / browser / defaults / profile``/ Users / noit / Desktop / Firefox - dev.app / Contents / Resources / browser / defaults / profile`
`ARes` /Applications/Firefox.app/Contents/Resources/浏览器/ res /`/用户/ noit /桌面/火狐 - dev.app /内容/资源/浏览器/ res`
`AChrom` /应用程序/ Firefox.app /内容/资源/浏览器/ / Users / noit / Desktop / Firefox - dev.app / Contents / Resources / browser / chrome`
` APlugns` / Applications / Firefox.app / Contents / Resources / browser / plugins` / Users / noit / Desktop / Firefox - dev.app / Contents / Resources / browser / plugins`
`SrchPlugns` / Applications / Firefox.app / Contents / Resources / browser / searchplugins``/ Users / noit / Desktop / Firefox - dev .app / Contents / Resources / browser / searchplugins`
`Pro fld`` /Users/noit/Library/Caches/Firefox/Profiles/jv5ijq47.Unnamed Profile 1`` / Users / noit / Library / Application Support / Firefox / Profiles / jv5ijq47.Unnamed Profile 1`
`XPIClnupD` `/ Applications / Firefox.app / Contents / Resources / browser``/ Users / noit / Desktop / Firefox - dev.app / Contents / Resources / browser`
`CurProcD``/Applications/Firefox.app/Contents / Resources / browser /`/ Users / noit / Desktop / Firefox - dev.app / Contents / Resources / browser`
`XCurProcD`` / Applications / Firefox.app / Contents / Resources / noit / Desktop / Firefox - dev.app / Contents / Resources / browser`
`XpcomLib``/ Applications / Firefox.app / Contents / MacOS / XUL`` / Users / noit / Desktop / Firefox - dev.app / Contents / MacOS / XUL`
`GreD`` / Applications / Firefox.app / Contents / Resources``/ Users / noit / Desktop / Firefox - dev.app / Contents / Resources`
`GreBinD `` / Applications / Firefox.app / Contents / MacOS`` / Users / noit / Desktop / Firefox - dev.app / Contents / MacOS`

$ b $我觉得我正朝着正确的方向前进:

toolkit / mozapps / update / tests / unit_aus_update / head_update.js#3389rel =nofollow> https://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/update/tests/unit_aus_update/head_update。 js#3389



如果您将以下代码复制粘贴,则会替换路径: Cc [@ mozilla。 org / file / directory_service; 1]。getService(Ci.nsIProperties).get('XREExeF',Ci.nsIFile).path; 但是如果你做了 FileUtils.getFile ('XREExeF',[])它抛出

$ block
异常...组件返回失败代码: 0x80520015
(NS_ERROR_FILE_ACCESS_DENIED)[nsIFile.create]nsresult:0x80520015
(NS_ERROR_FILE_ACCESS_DENIED)locati on:JS frame ::
resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70
data:no]


如何解决这个错误的任何想法?

我认为我真的在正确的轨道上!谢谢! :D

 函数do_get_file(path,allowNonexistent){//https://dxr.mozilla.org/mozilla-central/ source / mobile / android / base / tests / robocop_head.js#803 
try {
let lf = Components.classes [@ mozilla.org/file/directory_service;1]
。 getService(Components.interfaces.nsIProperties)
.get(CurWorkD,Components.interfaces.nsILocalFile);

let bits = path.split(/);
if(bits [i] ==..){
for(let i = 0; i if(bits [i])
lf = lf.parent;
else
lf.append(bits [i]); $!


$ if(!allowNonexistent&&!lf.exists()){
//不使用do_throw():调用者将继续。
_passed = false;
var stack = Components.stack.caller;
console.error(TEST-UNEXPECTED-FAIL |+ stack.filename +| [+
stack.name +:+ stack.lineNumber +]+ lf.path +
不存在\\\
);
}

return lf;
}
catch(ex){
console.error(ex.toString(),Components.stack.caller);
}

返回null;
}

var gTestID ='gTestID /';
函数getApplyDirPath(){
返回gTestID +/dir.app/;


函数getApplyDirFile(aRelPath,aAllowNonexistent){
let relpath = getApplyDirPath()+(aRelPath?aRelPath:);
返回do_get_file(relpath,aAllowNonexistent);
}
var DIR_MACOS ='DIR_MACOS';
var FILE_APP_BIN ='FILE_APP_BIN';
var XRE_EXECUTABLE_FILE ='XREExeF';
var XRE_UPDATE_ROOT_DIR ='XRE_UPDATE_ROOT_DIR';
let dirProvider = {
getFile:function AGP_DP_getFile(aProp,aPersistent){
aPersistent.value = true;
switch(aProp){
case XRE_EXECUTABLE_FILE:
return getApplyDirFile(DIR_MACOS + FILE_APP_BIN,true);
break;
}
返回null;

QueryInterface:function(aIID){
if(aIID.equals(Ci.nsIDirectoryServiceProvider)||
aIID.equals(Ci.nsISupports))
返回这个;
抛出Cr.NS_ERROR_NO_INTERFACE;
}
};

var ds = Services.dirsvc.QueryInterface(Ci.nsIDirectoryService);
ds.QueryInterface(Ci.nsIProperties).undefine('XREExeF');
console.log(rez)
ds.registerProvider(dirProvider);


This is a firefox-addon question, just tagging osx for ya.

On MacOS X I have copied the all contents of /Applications/Firefox.app to /Users/noit/Desktop/custom profile.app. Except all files are copied as alias (folders are copied as folders). Only non-alias file is the icon in custom profile.app/Contents/Resources/firefox.icns, i overrwrite that one with custom icon. (Well to be accurate, the plist.info is copied but CFBundleExecutable is changed to a new exec i place in the MacOS folder, which launches the firefox from MacOS with command line arguments to ensure right profile launches)

This allows me to run a seperate profile as a "shortcut". Now if user "Keeps in Dock" the dock icon that shows, or on restart of computer marks "Re-open windows from last time", or if user right clicks dock icon and says "Open at log in", or if user restarts Firefox it properly launches back into right profile. Added bonus is it obeys the custom icon.

Some issues when running a profile out of here:

  • On update, the files are written to the /Desktop/custom profile.app, not the Applications/Firefox.app. So right now on browser startup, i test if its first time starting up in update profile, and if so, then I ensure to copy the newly made files back to Applications/Firefox.app and set them as alias's in my /Desktop/custom profile.app. __Is there any way for me to change the path so it updates to Applications/Firefox.app?
  • The other issue is, some special paths are now pointing differently, like FileUtils.getFile('XREExeF', []).path is now /Desktop/custom profile.app/Contents/MacOS/firefox instead of Applications/Firefox.app/...., is there anyway for me to change this to be the Applications path?

Thanks

EDIT:

Here is a diff between the regular app on right and alias copied app on left:

https://www.diffchecker.com/lihx3o8w

So the keys that got changed are a total of 20:

Key             Regular.app                                                                 Alias.app
`XREExeF`       `/Applications/Firefox.app/Contents/MacOS/firefox`                          `/Users/noit/Desktop/Firefox - dev.app/Contents/MacOS/firefox`
`ProfLDS`       `/Users/noit/Library/Caches/Firefox/Profiles/jv5ijq47.Unnamed Profile 1`    `/Users/noit/Library/Application Support/Firefox/Profiles/jv5ijq47.Unnamed Profile 1`
`XREAppDist`    `/Applications/Firefox.app/Contents/Resources/distribution`                 `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/distribution`
`UpdRootD`      `/Users/noit/Library/Caches/Mozilla/updates/Applications/Firefox`           `/Users/noit/Library/Caches/Mozilla/updates/Users/noit/Desktop/Firefox - dev`
`DefRt`         `/Applications/Firefox.app/Contents/Resources/browser/defaults`             `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/defaults`
`PrfDef`        `/Applications/Firefox.app/Contents/Resources/defaults/pref`                `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/defaults/pref`
`profDef`       `/Applications/Firefox.app/Contents/Resources/browser/defaults/profile`     `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/defaults/profile`
`ProfDefNoLoc`  `/Applications/Firefox.app/Contents/Resources/browser/defaults/profile`     `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/defaults/profile`
`ARes`          `/Applications/Firefox.app/Contents/Resources/browser/res`                  `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/res`
`AChrom`        `/Applications/Firefox.app/Contents/Resources/browser/chrome`               `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/chrome`
`APlugns`       `/Applications/Firefox.app/Contents/Resources/browser/plugins`              `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/plugins`
`SrchPlugns`    `/Applications/Firefox.app/Contents/Resources/browser/searchplugins`        `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/searchplugins`
`ProfLD`        `/Users/noit/Library/Caches/Firefox/Profiles/jv5ijq47.Unnamed Profile 1`    `/Users/noit/Library/Application Support/Firefox/Profiles/jv5ijq47.Unnamed Profile 1`
`XPIClnupD`     `/Applications/Firefox.app/Contents/Resources/browser`                      `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser`
`CurProcD`      `/Applications/Firefox.app/Contents/Resources/browser`                      `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser`
`XCurProcD`     `/Applications/Firefox.app/Contents/Resources/browser`                      `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser`
`XpcomLib`      `/Applications/Firefox.app/Contents/MacOS/XUL`                              `/Users/noit/Desktop/Firefox - dev.app/Contents/MacOS/XUL`
`GreD`          `/Applications/Firefox.app/Contents/Resources`                              `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources`
`GreBinD`       `/Applications/Firefox.app/Contents/MacOS`                                  `/Users/noit/Desktop/Firefox - dev.app/Contents/MacOS`

解决方案

I think I'm going in the right direction: https://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/update/tests/unit_aus_update/head_update.js#3389

If you copy paste this code below it will replace the path if you do: Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get('XREExeF', Ci.nsIFile).path; but if you do FileUtils.getFile('XREExeF', []) it throws

[Exception... "Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIFile.create]" nsresult: "0x80520015 (NS_ERROR_FILE_ACCESS_DENIED)" location: "JS frame :: resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70" data: no]

Any ideas on how to fix this error?

I think im really on the right track! wee thanks! :D

function do_get_file(path, allowNonexistent) { //https://dxr.mozilla.org/mozilla-central/source/mobile/android/base/tests/robocop_head.js#803
  try {
    let lf = Components.classes["@mozilla.org/file/directory_service;1"]
      .getService(Components.interfaces.nsIProperties)
      .get("CurWorkD", Components.interfaces.nsILocalFile);

    let bits = path.split("/");
    for (let i = 0; i < bits.length; i++) {
      if (bits[i]) {
        if (bits[i] == "..")
          lf = lf.parent;
        else
          lf.append(bits[i]);
      }
    }

    if (!allowNonexistent && !lf.exists()) {
      // Not using do_throw(): caller will continue.
      _passed = false;
      var stack = Components.stack.caller;
      console.error("TEST-UNEXPECTED-FAIL | " + stack.filename + " | [" +
            stack.name + " : " + stack.lineNumber + "] " + lf.path +
            " does not exist\n");
    }

    return lf;
  }
  catch (ex) {
    console.error(ex.toString(), Components.stack.caller);
  }

  return null;
}

var gTestID = 'gTestID/';
function getApplyDirPath() {
  return gTestID + "/dir.app/";
}

function getApplyDirFile(aRelPath, aAllowNonexistent) {
  let relpath = getApplyDirPath() + (aRelPath ? aRelPath : "");
  return do_get_file(relpath, aAllowNonexistent);
}
var DIR_MACOS = 'DIR_MACOS';
var FILE_APP_BIN = 'FILE_APP_BIN';
var XRE_EXECUTABLE_FILE = 'XREExeF';
var XRE_UPDATE_ROOT_DIR = 'XRE_UPDATE_ROOT_DIR';
let dirProvider = {
    getFile: function AGP_DP_getFile(aProp, aPersistent) {
      aPersistent.value = true;
      switch (aProp) {
        case XRE_EXECUTABLE_FILE:
            return getApplyDirFile(DIR_MACOS + FILE_APP_BIN, true);
          break;
      }
      return null;
    },
    QueryInterface: function(aIID) {
      if (aIID.equals(Ci.nsIDirectoryServiceProvider) ||
          aIID.equals(Ci.nsISupports))
        return this;
      throw Cr.NS_ERROR_NO_INTERFACE;
    }
  };

var ds = Services.dirsvc.QueryInterface(Ci.nsIDirectoryService);
ds.QueryInterface(Ci.nsIProperties).undefine('XREExeF');
console.log(rez)
ds.registerProvider(dirProvider);

这篇关于OSX - 更改特殊路径,尤其是传送更新的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆