pathinfo.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_PATHINFO_H
  9. #define IGL_PATHINFO_H
  10. #include "igl_inline.h"
  11. #include <string>
  12. namespace igl
  13. {
  14. //// Decided not to use these
  15. //const int PATHINFO_DIRNAME 01
  16. //const int PATHINFO_BASENAME 02
  17. //const int PATHINFO_EXTENSION 04
  18. //const int PATHINFO_FILENAME 08
  19. /// Function like PHP's pathinfo to return information about path
  20. ///
  21. /// @param[in] path string containing input path
  22. /// @param[out] dirname string containing dirname (see dirname.h)
  23. /// @param[out] basename string containing basename (see basename.h)
  24. /// @param[out] extension string containing extension (characters after last '.')
  25. /// @param[out] filename string containing filename (characters of basename
  26. /// before last '.')
  27. ///
  28. ///
  29. /// #### Examples
  30. ///
  31. /// input | dirname basename ext filename
  32. /// "/" | "/" "" "" ""
  33. /// "//" | "/" "" "" ""
  34. /// "/foo" | "/" "foo" "" "foo"
  35. /// "/foo/" | "/" "foo" "" "foo"
  36. /// "/foo//" | "/" "foo" "" "foo"
  37. /// "/foo/./" | "/foo" "." "" ""
  38. /// "/foo/bar" | "/foo" "bar" "" "bar"
  39. /// "/foo/bar." | "/foo" "bar." "" "bar"
  40. /// "/foo/bar.txt" | "/foo" "bar.txt" "txt" "bar"
  41. /// "/foo/bar.txt.zip" | "/foo" "bar.txt.zip" "zip" "bar.txt"
  42. /// "/foo/bar.dir/" | "/foo" "bar.dir" "dir" "bar"
  43. /// "/foo/bar.dir/file" | "/foo/bar.dir" "file" "" "file"
  44. /// "/foo/bar.dir/file.txt" | "/foo/bar.dir" "file.txt" "txt" "file"
  45. ///
  46. /// \see basename, dirname
  47. IGL_INLINE void pathinfo(
  48. const std::string & path,
  49. std::string & dirname,
  50. std::string & basename,
  51. std::string & extension,
  52. std::string & filename);
  53. }
  54. #ifndef IGL_STATIC_LIBRARY
  55. # include "pathinfo.cpp"
  56. #endif
  57. #endif