Determine User Directories on OS X?

BlitzMax Forums/BlitzMax Programming/Determine User Directories on OS X?

Garrett(Posted 2006) [#1]
Greetings,

Does anyone know how to determine the locations of user directories on OS X
from BMax? I browsed the docs but didn't see any built in function for this :-(

Or! How to find out the name of the current user?

Purpose is that I want to put a settings file in the users section, such as:
"/Users/usernamehere/Library/Preferences/myproggysettings.txt"

Thanks,
-Garrett


WendellM(Posted 2006) [#2]
This seems to work for me on my Mac (you could either grab f if there's only one, or else offer a choice if multiple):
Strict
Local folders$[] = LoadDir("/Users")

For Local f$ = EachIn folders
        If f[0..1] <> "." And f <> "Shared" Then Print f 
Next
However, my OS X experience/familiarity isn't up to that for Windows, so other stuff that might show up the Users folder (on other systems that I'm unaware of) might need to be filtered out (or you might want to included "Shared"?).


ragtag(Posted 2006) [#3]
See this post by Mark http://www.blitzbasic.com/Community/posts.php?topic=42019#471219

It's a bit old, so I don't know if it still applies or if there is a simpler way to do it.

Ragnar


Winni(Posted 2006) [#4]
Mark´s code still works nicely on OS X 10.4.7 (for Intel).


xlsior(Posted 2006) [#5]
Under Linux/Unix, the current user home directory will always be '~'

so that could be "~/Library/Preferences/myproggysettings.txt"
without the need to know the actual username.

I don't know much about OSX, but doesn't it work the same thanks to its Unix/BSD ancestry?


Garrett(Posted 2006) [#6]
I believe the tilde works on OS X also. Thanks everyone for the info. :-)

-Garrett


Garrett(Posted 2006) [#7]
Well, for other stuff it does, but doesn't seem to affect BlitzMax in anyway. But!
tried that code from Mark Sibly, noted by Ragnar up there, and that does the
job just fine.

Thanks to everyone who replied,
-Garrett


DannyD(Posted 2006) [#8]
Believe it or not there is a Mac OS X forum here but it's hard to find. I'm trying to get the forum administrator to move the Mac os X forum from the very bottom of the forum lists to the BlitzMax category. Considering the only Blitz product available for Mac os X is BlitzMax it makes sense. Currently Mac topics end up in the general forum and disappear very quickly. I urge all Mac users who would like to see the forum promoted and visible to all to contact the Blitz webmaster using this link http://www.blitzbasic.com/Contact/_index_.php If anyone knows the website administrator personally please drop him a line asking for him to move the Mac forum to the BlitzMax forum. Thanks.


Hotcakes(Posted 2006) [#9]
The seperate Mac, Windows and Linux forums at the bottom of the list are basically OS specific General forums - they are not limited to BlitzMax talk.