pathinfo.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  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
  20. // returns information about path
  21. // Input:
  22. // path string containing input path
  23. // Outputs:
  24. // dirname string containing dirname (see dirname.h)
  25. // basename string containing basename (see basename.h)
  26. // extension string containing extension (characters after last '.')
  27. // filename string containing filename (characters of basename before last
  28. // '.')
  29. //
  30. //
  31. // Examples:
  32. //
  33. // input | dirname basename ext filename
  34. // "/" | "/" "" "" ""
  35. // "//" | "/" "" "" ""
  36. // "/foo" | "/" "foo" "" "foo"
  37. // "/foo/" | "/" "foo" "" "foo"
  38. // "/foo//" | "/" "foo" "" "foo"
  39. // "/foo/./" | "/foo" "." "" ""
  40. // "/foo/bar" | "/foo" "bar" "" "bar"
  41. // "/foo/bar." | "/foo" "bar." "" "bar"
  42. // "/foo/bar.txt" | "/foo" "bar.txt" "txt" "bar"
  43. // "/foo/bar.txt.zip" | "/foo" "bar.txt.zip" "zip" "bar.txt"
  44. // "/foo/bar.dir/" | "/foo" "bar.dir" "dir" "bar"
  45. // "/foo/bar.dir/file" | "/foo/bar.dir" "file" "" "file"
  46. // "/foo/bar.dir/file.txt" | "/foo/bar.dir" "file.txt" "txt" "file"
  47. // See also: basename, dirname
  48. IGL_INLINE void pathinfo(
  49. const std::string & path,
  50. std::string & dirname,
  51. std::string & basename,
  52. std::string & extension,
  53. std::string & filename);
  54. }
  55. #ifndef IGL_STATIC_LIBRARY
  56. # include "pathinfo.cpp"
  57. #endif
  58. #endif