File paths and portability

Hello!

As my first game is reaching the final stage of development (not my very first
game, but the first one to positively reach a final stage), I’m starting to
think about how to distribute the files.

Although I’m developing in Linux, the current version still puts all the
resource files, the configuration and highscore files and the executable in a
common base directory. The game then uses relative paths to access the
various resource files.

While this seems to be the common way to distribute Windows games, I guess I
should split up my file structure for the Linux distribution (the executable
to /usr/games, the resources to /usr/share/games/mygame, and I guess the
config and highscore files to ~/.mygame?).

What I’m wondering now is: What is the usual way to access these files from
the program? Use a global define for the data directory and set it
differently for each platform, like “./” for Windows and
"/usr/share/games/mygame/" for Linux?

Seems like a stupid question perhaps, but I’m trying to be careful and keep
other potential target platforms I don’t yet know about (e.g. Apple) in mind.
Also, I’m not sure yet if some Linux distributions might prefer to have the
resource files in a different directory, so perhaps to “play nice”, should I
make the resource path configurable during the build process?

Thx,
Marian.–
Hofstadter’s law: “It always takes longer than you think,
even when you take account of Hofstadter’s law”.

What I’m wondering now is: What is the usual way to access these files from
the program? Use a global define for the data directory and set it
differently for each platform, like “./” for Windows and
"/usr/share/games/mygame/" for Linux?

Marian,

When faced with the same problem, I wrote this:
http://www.maccormack.net/~djm/fnkdat/

It may work for you as well.

DaveOn Mon, 11 Apr 2005, Marian Schedenig wrote:

Any reason you’re releasing it as GPL versus LGPL (since it’s a kind of lib)?

I was thinking of using it in a commercial SDL game I might be working on,
but (aside from working out a specific licensing deal with you) cannot.

As an aside, this might be mighty useful for Tux Paint (which is itself GPL),
although it supports Mac OS X and BeOS, along with Linux, Windows and Un*xes.
I’ll see what the other developers think.

Thx!

-bill!On Mon, Apr 11, 2005 at 05:00:06PM -0400, David MacCormack wrote:

When faced with the same problem, I wrote this:
http://www.maccormack.net/~djm/fnkdat/

When faced with the same problem, I wrote this:
http://www.maccormack.net/~djm/fnkdat/

Any reason you’re releasing it as GPL versus LGPL (since it’s a kind of lib)?

Heh, duh, then I read below, you have some kind of exception stuff.
Sorry :^)

(Curious, though, why it wouldn’t have been easier to LGPL, rather than to
GPL-with-exceptions?)

-bill!On Mon, Apr 11, 2005 at 02:45:42PM -0700, Bill Kendrick wrote:

On Mon, Apr 11, 2005 at 05:00:06PM -0400, David MacCormack wrote:

'lo Marian,On 11/04/2005, Marian Schedenig, you wrote:

What I’m wondering now is: What is the usual way to access these files
from the program? Use a global define for the data directory and set
it differently for each platform, like “./” for Windows and
"/usr/share/games/mygame/" for Linux?

I just programmed today a function to solve this problem in my game. It
returns the path to the prefs file. I suggest you use a function
instead of a define because you might need some code to “compute” the
correct path under some systems. Also, if you need to create a
directory to put your prefs file into (like “~/.yourgame/” maybe), you
can put an mkdir() in that function.

So far I’m using the following dirs to store the prefs :

  • AmigaOS/MorphOS : the game dir.

  • Windows : the game dir, but I’m told this won’t work everywhere. Under
    2000/XP, I think it should go into “c:\Document and
    settings\user\yourgame”… There’s probably an OS call to determine
    that.

  • MacOS X : ~/Library/Preferences/YourGame (YourGame can be a dir or a
    file). It seems that you can’t use “~” in fopen(), so use
    getenv(“HOME”) instead. (still got to try that one… couldn’t find a
    working svn client to checkout my sources and try that today.)

  • Linux : ~/.mygame (file or dir, doesn’t matter)


Olivier.
Please remove “.ARGL.invalid” from my email when replying.
Incoming HTML mails are automatically deleted.

When faced with the same problem, I wrote this:
http://www.maccormack.net/~djm/fnkdat/

Any reason you’re releasing it as GPL versus LGPL (since it’s a kind of lib)?

Heh, duh, then I read below, you have some kind of exception stuff.
Sorry :^)

(Curious, though, why it wouldn’t have been easier to LGPL, rather than to
GPL-with-exceptions?)

Hi Bill. Basically, it just sort of evolved that way. I originally
wrote it as an LGPL library. Then, I decided that because it’s so simple
and small (1 C file, 1 H file, and < 2K linked) it would probably be much
easier to allow developers to statically link it. So I started fishing
around and came across the license for GUILE, which I copied verbatim,
substituting fnkdat for guile. My thinking, originally, was to stay with
a GPL/copyleft license. But, in the end, I’m not sure it really makes
much sense. I’ve told other folks that I’d be willing to dual license it
under a BSD style license, or I may even just out right change it to an
MIT/BSD license with the next release. It retrospect, it’s probably a
lot more practical for this little bit of code. What can I say? This was
my first bit of open sourced code. Live and learn ;).

If you’d prefer a BSDesque license, let me know and I’ll update all of
the file headers and cut a new release.

Later,

DaveOn Mon, 11 Apr 2005, Bill Kendrick wrote:

On Mon, Apr 11, 2005 at 02:45:42PM -0700, Bill Kendrick wrote:

On Mon, Apr 11, 2005 at 05:00:06PM -0400, David MacCormack wrote:

I was looking for this lib :slight_smile:
Thanks for making it free!!

This license thing… it’s very confusing… why not just stick to GPL? GPL is free software which stays free. You can use GPL’ed software in commercial software. It’s free! You must publish any modifications so it stays free! Am I right, am I wrong?? How hard can it be to publish free software???–


Web-based SMS services available at http://www.operamail.com.

From your mailbox to local or overseas cell phones.

Powered by Outblaze

This license thing… it’s very confusing…

I do agree ;^)

why not just stick to GPL?

Because that would make it difficult to use in non-GPL products!!!

GPL is free software which stays free.
You can use GPL’ed software in commercial software.

Actually, the reason the LGPL was created (quoting the LGPL itself):

We use this license [the LGPL] for certain libraries in order to
permit linking those libraries into non-free programs.

because the GPL states:

b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any part
thereof, to be licensed as a whole at no charge to all third parties
under the terms of this License.

and:

This General Public License does not permit incorporating your program
into proprietary programs. If your program [the one you are
considering releasing as GPL] is a subroutine library [like libSDL or
FNKDAT], you may consider it more useful to permit linking proprietary
applications with the library. If this is what you want to do, use the
GNU Library General Public License [LGPL] instead of this License.

So if it weren’t for FNKDAT’s ‘exception’ clause, the GPL would prohibit
me from using FNKDAT in a commercial app. (Just as if libSDL were GPL,
instead of LGPL.)

It’s free! You must publish any modifications so it stays free! Am I
right, am I wrong?? How hard can it be to publish free software???

When you’re making a commercial product, it’s kind of hard to sell it if
it’s free. :^P

-bill!On Thu, Apr 14, 2005 at 11:57:21PM +0100, Eigil Hysvaer wrote:

Eigil Hysvaer wrote:

I was looking for this lib :slight_smile:
Thanks for making it free!!

This license thing… it’s very confusing… why not just stick to GPL? GPL is free software which stays free. You can use GPL’ed software in commercial software. It’s free! You must publish any modifications so it stays free! Am I right, am I wrong?? How hard can it be to publish free software???

You can not use GPL’ed code in commercial software… but You are able
to dynamical link a LGPL library to commercial software… BIG difference!–
Best regards,
hnl_dk - Henning Nielsen Lund

Thanks, I’ll have a closer look at it.

Marian.On Monday 11 April 2005 23:00, David MacCormack wrote:

When faced with the same problem, I wrote this:
http://www.maccormack.net/~djm/fnkdat/

It may work for you as well.


Hofstadter’s law: “It always takes longer than you think,
even when you take account of Hofstadter’s law”.