- if(thePath == "")
- return "";
- OSD_Path aPath = OSD_Path(TCollection_AsciiString(const_cast<char*>(thePath.c_str())));
- TCollection_AsciiString aDirString(aPath.Trek());
- aDirString.ChangeAll('|','/');
- return aDirString.ToCString();
+ if (thePath.empty()) return "";
+
+ size_t pos = thePath.rfind('/');
+ std::string path;
+ if(pos != std::string::npos) {
+ path = thePath.substr(0, pos+1);
+ }
+ if(path.empty()) {
+ pos = thePath.rfind('\\');
+ if(pos != std::string::npos) path = thePath.substr(0, pos+1);
+ }
+ if(path.empty()) {
+ pos = thePath.rfind('|');
+ if(pos != std::string::npos) path = thePath.substr(0, pos+1);
+ }
+ if(path.empty()) {
+ path = thePath+"/";
+ }
+
+#ifdef WIN32 //Check if the only disk letter is given as path
+ if(path.size() == 2 && path[1] == ':') path +='\\';
+#endif
+
+ for(size_t i = 0, len = path.size(); i<len; i++)
+ if(path[i] == '|') path[i] = '/';
+ return path;