Getting Data path on different OSes

Monkey Forums/Monkey Programming/Getting Data path on different OSes

Grey Alien(Posted 2012) [#1]
Hi all, so I'm using os.LoadString to load in level data for my game. The data is stored in the mygamename.data folder as you'd expect.

For Flash and HTML 5 it works fine without any path info.

For PC I'm having to do this: os.LoadString(ExtractDir(AppPath())+"/data/"+levelNumber+".txt")

Because if there's no path info I get this debug output: FOPEN 'rb' for LoadString '1.txt' failed

On Mac the PC code won't work because it'll need to go up a folder from the exe and then look in the resources/data folder. Obviously I can make it do that IF I know it's a Mac and not a PC.

So I have 2 questions:

1) Can I determine the OS with a compiler directive or at runtime?
2) Is there are better way to do this than my method above?

Many thanks for your help!