MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / Path_FilePathToUrl

Function Path_FilePathToUrl

samples/shared/pathtools.cpp:747–763  ·  view source on GitHub ↗

---------------------------------------------------------------------------------------------------------------------------- Purpose: Turns a path to a file on disk into a URL (or just returns the value if it's already a URL) ----------------------------------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

745// Purpose: Turns a path to a file on disk into a URL (or just returns the value if it's already a URL)
746// ----------------------------------------------------------------------------------------------------------------------------
747std::string Path_FilePathToUrl( const std::string & sRelativePath, const std::string & sBasePath )
748{
749 if ( !strnicmp( sRelativePath.c_str(), "http://", 7 )
750 || !strnicmp( sRelativePath.c_str(), "https://", 8 )
751 || !strnicmp( sRelativePath.c_str(), "file://", 7 ) )
752 {
753 return sRelativePath;
754 }
755 else
756 {
757 std::string sAbsolute = Path_MakeAbsolute( sRelativePath, sBasePath );
758 if ( sAbsolute.empty() )
759 return sAbsolute;
760 sAbsolute = Path_FixSlashes( sAbsolute, '/' );
761 return std::string( FILE_URL_PREFIX ) + sAbsolute;
762 }
763}
764
765// -----------------------------------------------------------------------------------------------------
766// Purpose: Strips off file:// off a URL and returns the path. For other kinds of URLs an empty string is returned

Callers

nothing calls this directly

Calls 4

emptyMethod · 0.80
strnicmpFunction · 0.70
Path_MakeAbsoluteFunction · 0.70
Path_FixSlashesFunction · 0.70

Tested by

no test coverage detected