| 1 |
/* |
| 2 |
Copyright (C) 1997-2026 Sam Lantinga <[email protected]> |
| 3 |
|
| 4 |
This software is provided 'as-is', without any express or implied |
| 5 |
warranty. In no event will the authors be held liable for any damages |
| 6 |
arising from the use of this software. |
| 7 |
|
| 8 |
Permission is granted to anyone to use this software for any purpose, |
| 9 |
including commercial applications, and to alter it and redistribute it |
| 10 |
freely. |
| 11 |
*/ |
| 12 |
/* Simple test of filesystem functions. */ |
| 13 |
|
| 14 |
#include <stdio.h> |
| 15 |
#include "SDL.h" |
| 16 |
#include "SDL_test.h" |
| 17 |
|
| 18 |
int main(int argc, char *argv[]) |
| 19 |
{ |
| 20 |
char *base_path; |
| 21 |
char *pref_path; |
| 22 |
SDLTest_CommonState *state; |
| 23 |
|
| 24 |
state = SDLTest_CommonCreateState(argv, 0); |
| 25 |
if (!state) { |
| 26 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDLTest_CommonCreateState failed: %s\n", SDL_GetError()); |
| 27 |
return 1; |
| 28 |
} |
| 29 |
|
| 30 |
/* Enable standard application logging */ |
| 31 |
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); |
| 32 |
|
| 33 |
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { |
| 34 |
return 1; |
| 35 |
} |
| 36 |
|
| 37 |
if (!SDLTest_CommonInit(state)) { |
| 38 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); |
| 39 |
return 1; |
| 40 |
} |
| 41 |
|
| 42 |
base_path = SDL_GetBasePath(); |
| 43 |
if (!base_path) { |
| 44 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n", |
| 45 |
SDL_GetError()); |
| 46 |
} else { |
| 47 |
SDL_Log("base path: '%s'\n", base_path); |
| 48 |
SDL_free(base_path); |
| 49 |
} |
| 50 |
|
| 51 |
pref_path = SDL_GetPrefPath("libsdl", "test_filesystem"); |
| 52 |
if (!pref_path) { |
| 53 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n", |
| 54 |
SDL_GetError()); |
| 55 |
} else { |
| 56 |
SDL_Log("pref path: '%s'\n", pref_path); |
| 57 |
SDL_free(pref_path); |
| 58 |
} |
| 59 |
|
| 60 |
pref_path = SDL_GetPrefPath(NULL, "test_filesystem"); |
| 61 |
if (!pref_path) { |
| 62 |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s\n", |
| 63 |
SDL_GetError()); |
| 64 |
} else { |
| 65 |
SDL_Log("pref path: '%s'\n", pref_path); |
| 66 |
SDL_free(pref_path); |
| 67 |
} |
| 68 |
|
| 69 |
SDLTest_CommonQuit(state); |
| 70 |
return 0; |
| 71 |
} |