-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mac OS support for Utility::Directory::configurationDir() #6
Comments
For Mac OS X and iOS you need to use the CFBundleRef and use it to access your files that are saved within the app resource bundle, because of the sandboxing issue. Here is the code example I use to access the files from within the Mac OS X app bundle (it uses a singleton class of my own, but you can ignore that): macbundle.hpp
macbundle.cpp
The same code would work with no difference on iOS as well. |
Relevant Apple documentation on Bundles: In my code above that was written in C++, you can call the |
Oh, thanks a lot for the code! Speaking about this, I have access to Apple hardware now, so I can definitely look into this and fix it. Actually, I need something like this tomorrow :D
Another thing: would |
The issue is sandboxing. You have very limited places where you can download and save your own stuff, except the access of files from within the bundles. If you try to access outside the limits imposed by the sandboxing, you get failures like user permissions needed etc. Also look there for the C functions: http://opensource.apple.com//source/CF/CF-550/CFBundle.h It has also additional functions allowing you to load the plugins dynamically like those CFBundleLoadExecutable and CFBundleUnloadExecutable etc. |
Also if you see in Apple documentation the requirement to use ObjC functions, you can use associated CF functions like: NSHomeDirectory is equivalent to CFCopyHomeDirectoryURL ( http://stackoverflow.com/a/12717548 ) A solution for creating temporary files: http://stackoverflow.com/a/12714258 Also kinda incomplete C++ wrapper for CoreFoundation: Thinking more about the sandboxing, I think we are forced to use some ObjC++ to use some specific Core Foundation functions that are not available as C functions to be called from C code. |
OSX/iOS sandbox support for Opened a new issue #23 to track dynamic plugin support on iOS. Thanks a lot for the very detailed help! |
Class Utility::Directory has various functions for dealing with filesystem and they are currently implemented for and tested on Linux and Windows only, as I don't have access to any Apple hardware where I could test that. Current implementation status:
list()
mkpath()
andhome()
are POSIX-compatible and should just workrm()
andmove()
should work for files, but I'm not sure about directorieshome()
returns valueHOME
environment variable (also POSIX-compatible) and thus should work tooconfigurationDir("App")
currently returns~/.config/app
, which is not wanted. It should return some directory under~/Library/
(the correct path is returned by some system API -- relevant SO thread).The text was updated successfully, but these errors were encountered: