Mac 操作系统文件夹位置
我们有一个应用程序正在从 Windows 移植到 Mac OS。安装后,用户可以通过使用文本编辑器编辑某些批准的“数据文件”来自定义应用程序的功能。保存后,可以重新加载应用程序以编译和加载内容。该程序的核心部分是这些数据文件的编辑和共享,并且该程序提供了一个友好的界面来允许用户编辑它们。
在 Windows 上,这些文件夹位于标准文件夹下,通过 shell 常量访问,我们的安装程序使所有用户都可以访问该文件夹。安装后,任何用户都可以运行该应用程序并编辑它使用的数据文件。
Mac 上使用的等效文件夹是什么?我们是否可以在某个地方放置所有用户通常都可以访问的内容,或者我们是否必须以某种方式将其标记为“所有用户都可以访问”?
编辑:一些用户建议使用 /Users/Shared。 /Users/Shared 中的文件是否仍然以某种方式限制于创建它们的用户?我记得尝试在 /Users/Shared 中的帐户之间复制文件,并且我必须先“取得 /Users/Shared 中文件的所有权”,然后才能对它们执行任何操作。
We have an application that we're porting to Mac OS from Windows. Once installed, the user can customize the functionality of the application by editing certain approved "data files" with a text editor. Once saved, the application can be reloaded to compile and load the contents. A core part of the program is the editing and sharing of these data files, and the program provides a friendly interface to allow the user to edit them.
On Windows, these folders are located under a standard folder, accessed through a shell constant, that our installer makes accessible to all users. Once installed, any user can run the application and edit the data files it uses.
What is the equivalent folder to use for the mac? Is there somewhere we can put stuff that is accessible to all users normally, or do we have to flag it as "all users can access" somehow?
Edit: A couple of users have suggested /Users/Shared. Aren't files in /Users/Shared still limited somehow to the user who created them? I remember trying to copy files between accounts in /Users/Shared, and I had to "take ownership" of the files in /Users/Shared before I could do anything with them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
阅读 此文档。它有一个关于放置应用程序文件的位置的部分。我怀疑
/Users/Shared
是您想要执行的操作的正确目录;/Library/Application Support/
中的子目录可能更合适。但请记住,默认情况下非管理员用户将无法在那里写入。在这种情况下,您可以转而使用用户主文件夹中的相应目录。不要将路径硬编码到特殊目录。相反,您应该使用
NSFileManager
方法URLsForDirectory:inDomains:
或URLForDirectory:inDomain:propertyForURL:create:error:
,或者来自Carbon 如果你不使用 Objective-C。Read this document. It has a section on where to put application files. I doubt
/Users/Shared
is the right directory for what you want to do; a subdirectory within/Library/Application Support/
is probably more appropriate. Remember, though, that non-admin users will not be able to write there by default. In that case, you can fall back to using the corresponding directory in the user's home folder.Don't hardcode paths to special directories. Rather, you should use the
NSFileManager
methodsURLsForDirectory:inDomains:
orURLForDirectory:inDomain:appropriateForURL:create:error:
, or the Folder Manager from Carbon if you're not using Objective-C.Mac 上的 /Users/Shared 是任何用户都可以使用的文件夹。希望这有帮助。
/Users/Shared on a Mac is a folder available to any user. Hope this helps.
使用
/Users/Shared/your_application_name
。Use
/Users/Shared/your_application_name
.