🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.7 KiB

  1. /*
  2. Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
  3. This software is provided 'as-is', without any express or implied
  4. warranty. In no event will the authors be held liable for any damages
  5. arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it
  8. freely.
  9. */
  10. /* Simple test of filesystem functions. */
  11. #include <stdio.h>
  12. #include "SDL.h"
  13. int
  14. main(int argc, char *argv[])
  15. {
  16. char *base_path;
  17. char *pref_path;
  18. /* Enable standard application logging */
  19. SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
  20. if (SDL_Init(0) == -1) {
  21. SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
  22. return 1;
  23. }
  24. base_path = SDL_GetBasePath();
  25. if(base_path == NULL){
  26. SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n",
  27. SDL_GetError());
  28. return 1;
  29. }
  30. SDL_Log("base path: '%s'\n", base_path);
  31. SDL_free(base_path);
  32. pref_path = SDL_GetPrefPath("libsdl", "testfilesystem");
  33. if(pref_path == NULL){
  34. SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n",
  35. SDL_GetError());
  36. return 1;
  37. }
  38. SDL_Log("pref path: '%s'\n", pref_path);
  39. SDL_free(pref_path);
  40. pref_path = SDL_GetPrefPath(NULL, "testfilesystem");
  41. if(pref_path == NULL){
  42. SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s\n",
  43. SDL_GetError());
  44. return 1;
  45. }
  46. SDL_Log("pref path: '%s'\n", pref_path);
  47. SDL_free(pref_path);
  48. SDL_Quit();
  49. return 0;
  50. }