GetDataFilePathNull

This commit is contained in:
Sebastian Krzyszkowiak 2016-12-11 14:45:35 +01:00
parent 5eeba6ec45
commit 5839a6a59a
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 33 additions and 0 deletions

View file

@ -320,6 +320,38 @@ SYMBOL_EXPORT char* GetDataFilePath(struct Game *game, char* filename) {
return AddGarbage(game, result);
}
SYMBOL_EXPORT char* GetDataFilePathNull(struct Game *game, char* filename) {
char *result = 0;
if (al_filename_exists(filename)) {
return AddGarbage(game, strdup(filename));
}
{
char origfn[255] = "data/";
strcat(origfn, filename);
if (al_filename_exists(origfn)) {
return AddGarbage(game, strdup(origfn));
}
}
TestPath(filename, "data/", &result);
TestPath(filename, GetGameName(game, "../share/%s/data/"), &result);
TestPath(filename, "../data/", &result);
#ifdef ALLEGRO_MACOSX
TestPath(filename, "../Resources/data/", &result);
TestPath(filename, "../Resources/gamestates/", &result);
#endif
if (!result) {
return filename;
}
return AddGarbage(game, result);
}
ALLEGRO_DEBUG_CHANNEL("libsuperderpy")
SYMBOL_EXPORT void PrintConsole(struct Game *game, char* format, ...) {

View file

@ -55,6 +55,7 @@ ALLEGRO_BITMAP* LoadScaledBitmap(struct Game *game, char* filename, int width, i
/*! \brief Finds path for data file. */
char* GetDataFilePath(struct Game *game, char* filename);
char* GetDataFilePathNull(struct Game *game, char* filename);
char* GetGameName(struct Game *game, char* format);