简体   繁体   English

ForceDirectories无法在MacOS应用程序支持中创建文件夹

[英]ForceDirectories fails to create folders in MacOS Application Support

Delphi XE7 德尔福XE7

var
  theFolder: String;
...
theFolder := System.IOUtils.TPath.Combine(GetMacApplicationSupportDir, 'com.bookup.mychessapp' + Pathfinder;

ShowMessage(theFolder);

if ForceDirectories(theFolder)
  then ShowMessage('It worked.')
  else ShowMessage('It failed.');

ShowMessage now says it worked. ShowMessage现在说它起作用了。

theFolder is '/Users/mike/Library/Application Support/com.bookup.chessopeningswizardprofessional/' theFolder是'/ Users / mike / Library / Application Support / com.bookup.chessopeningswizardprofessional /'

That reverse URL matches the Bundle identifier in the app's info.plist. 该反向URL与应用程序的info.plist中的Bundle标识符匹配。

However, even though ForceDirectories() reports success, the folder does not appear in Macintosh HD | 但是,即使ForceDirectories()报告成功,该文件夹也不会出现在Macintosh HD中。 Library | 图书馆| Application Support (which has the folders for all the other apps). 应用程序支持(具有所有其他应用程序的文件夹)。

You want the Application Support directory under the System's Library directory, not the User's. 您需要系统库目录下的应用程序支持目录,而不是用户目录。

Your GetMacApplicationSupportDir function is probably passing NSUserDomainMask and is thus retrieving the Application Support directory under the User's Library directory. 您的GetMacApplicationSupportDir函数可能正在传递NSUserDomainMask ,因此正在检索用户库目录下的“应用程序支持”目录。

You should use NSSystemDomainMask if you want the Application Support directory under the System's Library directory. 如果要在系统的“库”目录下找到“应用程序支持”目录,则应使用NSSystemDomainMask


If ForceDirectories is still failing using the System level Application Support directory then you may not have appropriate admin (root) rights to create directories and files there. 如果ForceDirectories仍无法使用系统级应用程序支持目录,则您可能没有适当的管理员(root)权限在此处创建目录和文件。 This operation would typically be performed by and install process (which would have prompted for elevated admin/root rights.) 此操作通常由安装过程执行(这将提示提升管理员/根用户权限。)

Have a look at this question; 看看这个问题; it seems to be addressing a similar issue: 它似乎正在解决类似的问题:

Is /Library/Application Support Library accessible to all users? / Library / Application Support Library是否可供所有用户使用?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM