Opened 11 years ago

#41 new enhancement

Design away kludge in file opening code

Reported by: guest Owned by: Sam Hocevar
Priority: major Milestone: 1.0
Component: abuse Version: SVN
Keywords: Cc:


In order to determine whether get_filename_prefix()/spec_prefix should be prepended to the requested filename, both open_FILE() in game.cpp and jFILE::open_external() in imlib/specs.cpp currently use a kludge that bases the decision on whether or not the requested filename begins with a forward slash.

This is problematic for porting because some platforms require absolute paths that begin with something other than a slash (e.g., a device name), but it's also an odd design in general that requires the caller to know about and prepend the save path prefix but not the data path prefix.

I'm pretty sure that there are only two classes of files that the game should be attempting to open via these functions:

  1. Game data files, which should have get_filename_prefix() prepended, and
  2. Game save files, which should have get_save_filename_prefix() prepended.

As a result, it seems to me that a better design would be to either force the caller to prepend the prefixes ahead of time, or else parameterize(*) the functions to force the caller to specify which prefix should be prepended.

* - the parameter could be optional, defaulting to whichever prefix makes more sense.

Additionally, open_FILE() prepends a space between get_filename_prefix() and the filename, which might be a bug.

Change History (0)

Note: See TracTickets for help on using tickets.