Opened 6 years ago
Design away kludge in file opening code
|Reported by:||guest||Owned by:||sam|
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:
- Game data files, which should have get_filename_prefix() prepended, and
- 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.