ignorecase.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef INCL_PHYSFSEXT_IGNORECASE_H
  2. #define INCL_PHYSFSEXT_IGNORECASE_H
  3. /** \file ignorecase.h */
  4. /**
  5. * \mainpage PhysicsFS ignorecase
  6. *
  7. * This is an extension to PhysicsFS to let you handle files in a
  8. * case-insensitive manner, regardless of what sort of filesystem or
  9. * archive they reside in. It does this by enumerating directories as
  10. * needed and manually locating matching entries.
  11. *
  12. * Please note that this brings with it some caveats:
  13. * - On filesystems that are case-insensitive to start with, such as those
  14. * used on Windows or MacOS, you are adding extra overhead.
  15. * - On filesystems that are case-sensitive, you might select the wrong dir
  16. * or file (which brings security considerations and potential bugs). This
  17. * code favours exact case matches, but you will lose access to otherwise
  18. * duplicate filenames, or you might go down a wrong directory tree, etc.
  19. * In practice, this is rarely a problem, but you need to be aware of it.
  20. * - This doesn't do _anything_ with the write directory; you're on your
  21. * own for opening the right files for writing. You can sort of get around
  22. * this by adding your write directory to the search path, but then the
  23. * interpolated directory tree can screw you up even more.
  24. *
  25. * This code should be considered an aid for legacy code. New development
  26. * shouldn't do things that require this aid in the first place. :)
  27. *
  28. * Usage: Set up PhysicsFS as you normally would, then use
  29. * PHYSFSEXT_locateCorrectCase() to get a "correct" pathname to pass to
  30. * functions like PHYSFS_openRead(), etc.
  31. *
  32. * License: this code is public domain. I make no warranty that it is useful,
  33. * correct, harmless, or environmentally safe.
  34. *
  35. * This particular file may be used however you like, including copying it
  36. * verbatim into a closed-source project, exploiting it commercially, and
  37. * removing any trace of my name from the source (although I hope you won't
  38. * do that). I welcome enhancements and corrections to this file, but I do
  39. * not require you to send me patches if you make changes. This code has
  40. * NO WARRANTY.
  41. *
  42. * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license.
  43. * Please see LICENSE.txt in the root of the source tree.
  44. *
  45. * \author Ryan C. Gordon.
  46. */
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50. /**
  51. * \fn int PHYSFSEXT_locateCorrectCase(char *buf)
  52. * \brief Find an existing filename with matching case.
  53. *
  54. * This function will look for a path/filename that matches the passed in
  55. * buffer. Each element of the buffer's path is checked for a
  56. * case-insensitive match. The buffer must specify a null-terminated string
  57. * in platform-independent notation.
  58. *
  59. * Please note results may be skewed differently depending on whether symlinks
  60. * are enabled or not.
  61. *
  62. * Each element of the buffer is overwritten with the actual case of an
  63. * existing match. If there is no match, the search aborts and reports an
  64. * error. Exact matches are favored over case-insensitive matches.
  65. *
  66. * THIS IS RISKY. Please do not use this function for anything but legacy code.
  67. *
  68. * \param buf Buffer with null-terminated string of path/file to locate.
  69. * This buffer will be modified by this function.
  70. * \return zero if match was found, -1 if the final element (the file itself)
  71. * is missing, -2 if one of the parent directories is missing.
  72. */
  73. int PHYSFSEXT_locateCorrectCase(char *buf);
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif /* include-once blocker. */
  78. /* end of ignorecase.h ... */