globbing.h 2.9 KB

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