Changeset 9884 for OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp
- Timestamp:
- 03/10/09 13:21:13 (4 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgDB/FileNameUtils.cpp
r8912 r9884 180 180 } 181 181 182 183 182 184 bool osgDB::containsServerAddress(const std::string& filename) 183 185 { 184 // need to check for http:// 185 if (filename.size()<7) return false; 186 if (filename.compare(0,7,"http://")==0) return true; 187 return false; 186 // need to check for :// 187 std::string::size_type pos(filename.find_first_of("://")); 188 if (pos == std::string::npos) 189 return false; 190 std::string proto(filename.substr(0, pos)); 191 192 return Registry::instance()->isProtocolRegistered(proto); 193 } 194 195 std::string osgDB::getServerProtocol(const std::string& filename) 196 { 197 std::string::size_type pos(filename.find_first_of("://")); 198 if (pos != std::string::npos) 199 return filename.substr(0,pos); 200 201 return ""; 188 202 } 189 203 190 204 std::string osgDB::getServerAddress(const std::string& filename) 191 205 { 192 if (filename.size()>=7 && filename.compare(0,7,"http://")==0) 193 { 194 std::string::size_type pos_slash = filename.find_first_of('/',7); 206 std::string::size_type pos(filename.find_first_of("://")); 207 208 if (pos != std::string::npos) 209 { 210 std::string::size_type pos_slash = filename.find_first_of('/',pos+3); 195 211 if (pos_slash!=std::string::npos) 196 212 { 197 return filename.substr( 7,pos_slash-7);213 return filename.substr(pos+3,pos_slash-pos-3); 198 214 } 199 215 else 200 216 { 201 return filename.substr( 7,std::string::npos);217 return filename.substr(pos+3,std::string::npos); 202 218 } 203 219 } … … 207 223 std::string osgDB::getServerFileName(const std::string& filename) 208 224 { 209 if (filename.size()>=7 && filename.compare(0,7,"http://")==0) 210 { 211 std::string::size_type pos_slash = filename.find_first_of('/',7); 225 std::string::size_type pos(filename.find_first_of("://")); 226 227 if (pos != std::string::npos) 228 { 229 std::string::size_type pos_slash = filename.find_first_of('/',pos+3); 212 230 if (pos_slash!=std::string::npos) 213 231 {
