如何在 Cocoa 中将文件夹复制到系统文件夹
我正在可可中开发一个应用程序,它需要将一组文件复制到系统文件夹。将文件复制到系统文件夹时,我收到“权限被拒绝”错误消息。我该如何解决这个问题。
请任何人帮助我...
提前致谢
I am developing an application in cocoa which needs to copy a set of files to the system folder. When copying files to system folder I am getting a "Permission denied " error message . How can I resolve this problem.
Please any one help me...
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有必要在 /System 中放入任何内容,而且这可能不是一个好主意,因为它可能会被系统更新删除。我的猜测是,无论您想要做什么,都应该可以通过其他方式实现,例如使用 /Library 或 ~/Library。
It shouldn't be necessary to put anything in /System, and it's probably not a good idea anyway, as it could get wiped out by a system update. My guess is that whatever you're looking to do should be possible by some other means, e.g. using /Library or ~/Library.
Mac OS X 使用授权系统来防止应用程序在没有警告的情况下复制系统位置中的文件。这就是为什么您在安装框架时必须输入凭据的原因。
如果您想在应用程序中执行特权操作,我建议您阅读 授权服务编程指南,尤其是场景章节:它将帮助您决定如何进行文件复制。
Mac OS X uses a system of authorization that prevent application to copy files in system locations without warning. That's why you have to enter your credentials when installing a framework for example.
If you want to perform privileged operations in your application, I suggest you to read the Authorization Services Programming Guide and especially the Scenarios chapter: it will help you to decide how to do the file copy.
使用 PackageMaker 制作正确的安装程序包,就像我在您之前的问题中建议的那样。
Use PackageMaker to make a proper Installer package, like I suggested on your previous question.