Proper location for shared files & AppStore

Archives Forums/MacOS X Discussion/Proper location for shared files & AppStore

JazzieB(Posted 2011) [#1]
Sorry to start another thread, but the other one turned into a discussion about signing up as an Apple Developer and AppStore submissions. Anyways...

Part of the other thread goes into where to store files, but the question I need to ask was not answered. Where can I store files that need to be accessed by all users, such as a high score table? I've just discovered that the Library/Application Support folder is read-only for restricted users. Is there another location that is AppStore friendly? I believe the Shared folder is a no-go as far as the store is concerned.

Also, is there an official word on whether the features required by the AppStore will be built into a BlitzMax update, or do we have to use the work-a-rounds instead. I'm talking about full-screen quitting, and so on.


ima747(Posted 2011) [#2]
http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFileSystem/Articles/WhereToPutFiles.html

It *should* be /Library/Application Support in theory. I think asking on the official apple forum would get you more valid info for this.

I doubt that BlitzMax will get rebuilt around app store politeness any time soon so I would recommend building a list of the relevant additions you will need to make for your current project. Note also that you have to do certain things, however HOW you do them is still totally up to you. e.g. command Q has to quit, however you can do that by trapping the event, triggering app terminate, or just simply using polled input etc. there's no right way (though some are obviously much easier than others depending on how you lay things out).


JazzieB(Posted 2011) [#3]
The problem with that location is that restricted users can only read from that location, whereas I need them to write as well. I was using the /Users/Shared location, but this is not allowed, apparently. I'll see if I can find something in the information you've linked to.

And yes, if there are no official changes to the modules for AppStore compliance then I'll have to code it in myself. Just wondering if there was any word on this.

Cheers.


ima747(Posted 2011) [#4]
I would head to the apple forums for a solution to this personally. It's a matter of permissions management and app store compliance and they'll know a lot more about it over there. Of note because un-priviledged users can't write there doesn't mean they can't modify an existing file there if they have permission... unix style permission controls can get weird... Again apple forums will have people with more specific knowledge (I've never bothered with a shared local highscores table myself, either per user or global via the internet...). The official docs state, according to my interpretation (section 2, "Support Files") that It's supposed to go in "/Library/Application Support" but if you're encountering permission issues with this you'll need some more skilled help. You may for example need to build a blank or starter highscore table, and setup the signed installer to place that in the right location with the appropriate permissions (no clue how to do this specifically but should be possible, someone with more experience with the command line package builder should know) which in turn will trigger the OS for an administrator password to complete the installation... just a theory


Grey Alien(Posted 2011) [#5]
I used to use Users/Shared as it was most logical for all profiles to be able to use the same data, but complied with the path required by the app store. I also used a shared folder in Vista even though most games don't. It seems crazy to me as in the old days when you could store data in the game folder, anyone who logged on could share the same high scores etc.


Grey Alien(Posted 2011) [#6]
Oh yeah you can do this on the data folder and files: SetFileMode(Filename,%111111111)


JazzieB(Posted 2011) [#7]
Cheers Grey. Was going to look into that SetFileMode thing, as I know I had to do something with it anyway with some sort of weirdness happening when switching users. Even happened in Vista!

So does that work in the shared App Support folder?


Grey Alien(Posted 2011) [#8]
I know for sure that code worked on the old Users/Shared location I was using, and it's still running in that Library path and doesn't crash, so I guess it's OK.

I never used that code in Vista, I used some horrible complex thing to set permissions to Everyone. It's on the forums somewhere.


JazzieB(Posted 2011) [#9]
Thanks again. I'll give it a go later and report back. Got a feeling the game may first need to run from an admin account, as it also acts as a kind of installer the first time it runs, but we'll see.

I did get Vista to behave in the end using just SetFileMode, so hopefully I can bring OS X into line as well.


ima747(Posted 2011) [#10]
To remain app store compatible here's a couple thoughts:
Switch the "creating" (possibly just placing an empty copy) of the needed file(s) to the actual bundle installer. This is what apple intends so it's going to be the most by the book approach. However Making the installer do that... I have no idea via the command line tools that have to be used...

or

As you mentioned, require the first run to take place from an administrator account... this however is likely to run against the app store rules.

or

Store the highscores locally per user UNTIL it's running on an account with permissions, then merge the high scores from local to the global list... this will let it run within app store guidelines and, if possible, let you share the high scores... not totally elegant but it should satisfy everyone with minimal code (opening local library if the global library fails to open...).


JazzieB(Posted 2011) [#11]
Thanks for you thoughts.

Didn't think about the first run being from an admin account being against the App Store requirements, so must look into that.

Was actually thinking along the lines of your third idea, but not too sure how to do this at the moment so will have to give it some thought.


JazzieB(Posted 2011) [#12]
OK, so I finally got around to doing some testing and feel like a bit of a prat right now...

When I develop my games everything is stored in the documents folder of my admin account, naturally. So when it comes to testing under a restricted account I copy the app to the Applications folder, swap accounts, and test from there. The reason why my game crashed was not to do with permissions, but simply to do with me forgetting to copy the game data with it! The final version of the game will have the data contained within the App bundle. Anyways, to answer all of the above...

You can use the shared App Support folder without any issue. The only thing to remember is that whenever you create any files to use SetFileMode filename,%111111111 as soon as the file is created to maintain access for everyone, as Grey has already mentioned.

Glad that's sorted now.


Grey Alien(Posted 2011) [#13]
Phew, glad you sorted it out!


GfK(Posted 2011) [#14]
Does SetFileMode() work on folders? Just wondering if all that fannying about with folder permissions a couple of years back couldn't have been solved with the same function.


ima747(Posted 2011) [#15]
Glad it's sorted and documented, thanks!


JazzieB(Posted 2011) [#16]
Does SetFileMode() work on folders? Just wondering if all that fannying about with folder permissions a couple of years back couldn't have been solved with the same function.

Not sure, but it is how I've done it and it seems OK. I think I did have some issues with Vista, but it was some time ago now since I worked on this part of the code for Vista so can't remember the issues I had and how exactly I got around them. It may have needed a first run from an admin account or the installer to set everything up properly. I will be testing all of this again before release though.


GfK(Posted 2011) [#17]
Aye, Vista was where all the problems started!


Grey Alien(Posted 2011) [#18]
@GfK: Yeah I wondered the same thing when I posted that command the other day but then I'm pretty sure I wouldn't have done all that horrible file permissions stuff if this worked. It's so long ago I don't know the real answer... I suppose it could be tested, but I haven't inclination currently. That folder permissions did stuff like add Everyone and Users to the folder which I'm not convinced is the same as simple file permissions. I'm actually only using that command on Macs since a framework customer discovered it was needed in order to change users and still be able to play the game (which is really what my code is for on PC).


jkrankie(Posted 2011) [#19]
Bare in mind you can only read from the app bundle when you package for the app store. packagebuild changes the permissions and you can't change them back. It's fine to read data from the app bundle, but not write to it. you have to save to somewhere like Application Support.

Cheers
Charlie


Grey Alien(Posted 2011) [#20]
Yes I'm definitely only reading from it. All writing is in the approved path (on Mac and PC).