User directory in MacOS BMax

Archives Forums/MacOS X Discussion/User directory in MacOS BMax

Tricky(Posted 2008) [#1]
Hi there;

I'm currently working on a project in which people should be able to save their stuff in the user's documents dir. However how do you do that in BMax on MacOS.

I know the standard unix prefix for the userdir is ~, but BMax doesn't recognize it as so and appears to be looking for a dir named "~" that (of course) doesn't exist.

Is there another way to do this?


Manromen(Posted 2008) [#2]
In a terminal app type: "cd ~"

works same like in other unix OS's.

I don't know why this won't work in BlitzMax ... but it should .... :-/

[Edit]

try this: $userDir

does that work ?


Tricky(Posted 2008) [#3]
The terminal command "cd ~" works, but it's more that I'd like to do it this way.


File = WriteStream("~/myappdocs/document")

Well, that doesn't work, as BlitzMax doesn't see "~" as the user directory.


I've now done it on the "ugly" method...

Like this
(pseudo code. Not real code)
MakeBat "GetUserDir.bat","cd ~\npwd > /AppDir/UserDir.txt"
RunBat "GetUserDir"
UserDir = ReadString("/AppDir/UserDir.txt"

As I said peudo code, but you get the picture.
It is the "ugly" method, so if there's an official method, I'd like to know.


($userDir only got me errors)


Manromen(Posted 2008) [#4]
Ok - Sorry i don't know too :-)


Winni(Posted 2008) [#5]
Checkout Brucey's "volumes" mod:


A small cross-platform module for retrieving volume and directory information for the current system.

Also allows standard access to various user directories such as Home, Documents, Desktop and Application Data (Support on Mac).
The Application directory is where apps can store user-specific resources and such-like.



http://www.brucey.net/programming/blitz/index.php#bahvolumes


Tricky(Posted 2008) [#6]
Thanks a lot, Winni...
That covers my need ;)


Manromen(Posted 2008) [#7]
i can get my home folder with: getenv_("HOME")

No need for a module then :-)

[Edit]

this works for me:
file=OpenFile(getenv_("HOME") + "/test.txt")

Your Example should be:
File = WriteStream(getenv_("HOME") + "/myappdocs/document")


Tricky(Posted 2008) [#8]
I'll try that out... ;)


Brucey(Posted 2008) [#9]
HOME is an environment variable...

Bruceys-Mac-Mini:en brucey$ echo $HOME
/Users/brucey
Bruceys-Mac-Mini:en brucey$ export HOME=Woohoo
Bruceys-Mac-Mini:en brucey$ echo $HOME
Woohoo


Using APIs guarantees that things are where they are meant to be. Otherwise, why would we have APIs?


Manromen(Posted 2008) [#10]
Ah okay - that makes sense.

Thanks Brucey! :-)