SDL_filesystem.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <[email protected]>
  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. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "SDL_internal.h"
  19. #include "SDL_sysfilesystem.h"
  20. int SDL_RemovePath(const char *path)
  21. {
  22. if (!path) {
  23. return SDL_InvalidParamError("path");
  24. }
  25. return SDL_SYS_RemovePath(path);
  26. }
  27. int SDL_RenamePath(const char *oldpath, const char *newpath)
  28. {
  29. if (!oldpath) {
  30. return SDL_InvalidParamError("oldpath");
  31. } else if (!newpath) {
  32. return SDL_InvalidParamError("newpath");
  33. }
  34. return SDL_SYS_RenamePath(oldpath, newpath);
  35. }
  36. int SDL_CreateDirectory(const char *path)
  37. {
  38. /* TODO: Recursively create subdirectories */
  39. if (!path) {
  40. return SDL_InvalidParamError("path");
  41. }
  42. return SDL_SYS_CreateDirectory(path);
  43. }
  44. int SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata)
  45. {
  46. if (!path) {
  47. return SDL_InvalidParamError("path");
  48. } else if (!callback) {
  49. return SDL_InvalidParamError("callback");
  50. }
  51. return SDL_SYS_EnumerateDirectory(path, path, callback, userdata);
  52. }
  53. int SDL_GetPathInfo(const char *path, SDL_PathInfo *info)
  54. {
  55. SDL_PathInfo dummy;
  56. if (!info) {
  57. info = &dummy;
  58. }
  59. SDL_zerop(info);
  60. if (!path) {
  61. return SDL_InvalidParamError("path");
  62. }
  63. return SDL_SYS_GetPathInfo(path, info);
  64. }