12345678910111213141516171819202122232425262728293031323334353637383940 |
- #include "dirname.h"
- #include <algorithm>
- #include "verbose.h"
- IGL_INLINE std::string igl::dirname(const std::string & path)
- {
- if(path == "")
- {
- return std::string("");
- }
-
- size_t found = path.find_last_of("/\\");
- if(found == std::string::npos)
- {
-
- return std::string(".");
- }else if(found == 0)
- {
-
- return std::string(path.begin(),path.begin()+1);
- }else if(found == path.length()-1)
- {
-
- std::string redo = std::string(path.begin(),path.end()-1);
- return igl::dirname(redo);
- }
-
- return std::string(path.begin(),path.begin()+found);
- }
|