Code archives/File Utilities/osx resource file locations

This code has been declared by its author to be Public Domain code.

Download source code

osx resource file locations by AdamStrange2014
OSX stores everything in it's app file (which is really just a folder)
the structure is:
yourfile.App
> contents
> MacOS
> resources

When developing, you will need to have all your files properly inside the app file to work. this is a bit of a pain with debug version, etc.

so here is some quick code that looks inside the app folder
then will look inside the home folder/resources/
then the home folder

So, during development you can just store everything in a folder called resources while developing and then move into the app when finished

Here we see then font folder version:
Local FontDir:String = GetPreviousDir(GetPreviousDir(AppFile$) ) + "resources/font/"
If FileType(FontDir) <> 2 Then FontDir = AppDir$ + "/resources/font/"
If FileType(FontDir) <> 2 Then FontDir = AppDir$ + "/font/"
Print "fontdir="+FontDir

Comments

Brucey2014
I generally just use a post build script (post.bmk) which does relevant stuff like copying resources and dylibs into the app bundle. Then everything is always in the correct place.
Since my bmk_ng's scripting is lua-based, you can set it up to do quite complex stuff, all tied-in to the build system itself.


Code Archives Forum