00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_IO_PATH_INCLUDE
00013 #define MTL_IO_PATH_INCLUDE
00014
00015 namespace mtl { namespace io {
00016
00017 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
00018 const static char delim = '\\';
00019 #else
00020 const static char delim = '/';
00021 #endif
00022
00024
00025 std::string inline join(std::string directory, std::string file)
00026 {
00027 return directory.empty() ? file : directory + delim + file;
00028 }
00029
00031 std::string inline directory_name(std::string s)
00032 {
00033 for (int i= s.size() - 1; i >= 0; i--)
00034 if (s[i] == delim)
00035 return s.substr(0, i);
00036 return std::string();
00037 }
00038
00040 std::string inline file_name(std::string s)
00041 {
00042 for (int i= s.size() - 1; i >= 0; i--)
00043 if (s[i] == delim)
00044 return s.substr(i + 1);
00045 return s;
00046 }
00047
00048
00049
00050
00051 }}
00052
00053 #endif // MTL_IO_PATH_INCLUDE