ignorecase.h 3.3 KB

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