globbing.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef INCL_PHYSFSEXT_GLOBBING_H
  2. #define INCL_PHYSFSEXT_GLOBBING_H
  3. /** \file globbing.h */
  4. /**
  5. * \mainpage PhysicsFS globbing
  6. *
  7. * This is an extension to PhysicsFS to let you search for files with basic
  8. * wildcard matching, regardless of what sort of filesystem or archive they
  9. * reside in. It does this by enumerating directories as needed and manually
  10. * locating matching entries.
  11. *
  12. * Usage: Set up PhysicsFS as you normally would, then use
  13. * PHYSFSEXT_enumerateFilesPattern() when enumerating files. This is just
  14. * like PHYSFS_enumerateFiles(), but it returns a subset that matches your
  15. * wildcard pattern. You must call PHYSFS_freeList() on the results, just
  16. * like you would with PHYSFS_enumerateFiles().
  17. *
  18. * License: this code is public domain. I make no warranty that it is useful,
  19. * correct, harmless, or environmentally safe.
  20. *
  21. * This particular file may be used however you like, including copying it
  22. * verbatim into a closed-source project, exploiting it commercially, and
  23. * removing any trace of my name from the source (although I hope you won't
  24. * do that). I welcome enhancements and corrections to this file, but I do
  25. * not require you to send me patches if you make changes. This code has
  26. * NO WARRANTY.
  27. *
  28. * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license.
  29. * Please see LICENSE.txt in the root of the source tree.
  30. *
  31. * \author Ryan C. Gordon.
  32. */
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /**
  37. * \fn char **PHYSFS_enumerateFilesWildcard(const char *dir, const char *wildcard, int caseSensitive)
  38. * \brief Get a file listing of a search path's directory.
  39. *
  40. * Matching directories are interpolated. That is, if "C:\mydir" is in the
  41. * search path and contains a directory "savegames" that contains "x.sav",
  42. * "y.Sav", and "z.txt", and there is also a "C:\userdir" in the search path
  43. * that has a "savegames" subdirectory with "w.sav", then the following code:
  44. *
  45. * \code
  46. * char **rc = PHYSFS_enumerateFilesWildcard("savegames", "*.sav", 0);
  47. * char **i;
  48. *
  49. * for (i = rc; *i != NULL; i++)
  50. * printf(" * We've got [%s].\n", *i);
  51. *
  52. * PHYSFS_freeList(rc);
  53. * \endcode
  54. *
  55. * ...will print:
  56. *
  57. * \verbatim
  58. * We've got [x.sav].
  59. * We've got [y.Sav].
  60. * We've got [w.sav].\endverbatim
  61. *
  62. * Feel free to sort the list however you like. We only promise there will
  63. * be no duplicates, but not what order the final list will come back in.
  64. *
  65. * Wildcard strings can use the '*' and '?' characters, currently.
  66. * Matches can be case-insensitive if you pass a zero for argument 3.
  67. *
  68. * Don't forget to call PHYSFS_freeList() with the return value from this
  69. * function when you are done with it.
  70. *
  71. * \param dir directory in platform-independent notation to enumerate.
  72. * \return Null-terminated array of null-terminated strings.
  73. */
  74. __EXPORT__ char **PHYSFSEXT_enumerateFilesWildcard(const char *dir,
  75. const char *wildcard,
  76. int caseSensitive);
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif /* include-once blocker. */
  81. /* end of globbing.h ... */