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

Function Path_Join

samples/shared/pathtools.cpp:237–256  ·  view source on GitHub ↗

Jams two paths together with the right kind of slash */

Source from the content-addressed store, hash-verified

235
236/** Jams two paths together with the right kind of slash */
237std::string Path_Join( const std::string & first, const std::string & second, char slash )
238{
239 if( slash == 0 )
240 slash = Path_GetSlash();
241
242 // only insert a slash if we don't already have one
243 std::string::size_type nLen = first.length();
244 if( !nLen )
245 return second;
246#if defined(_WIN32)
247 if( first.back() == '\\' || first.back() == '/' )
248 nLen--;
249#else
250 char last_char = first[first.length()-1];
251 if (last_char == '\\' || last_char == '/')
252 nLen--;
253#endif
254
255 return first.substr( 0, nLen ) + std::string( 1, slash ) + second;
256}
257
258
259std::string Path_Join( const std::string & first, const std::string & second, const std::string & third, char slash )

Callers 2

Path_MakeAbsoluteFunction · 0.70

Calls 2

Path_GetSlashFunction · 0.70
lengthMethod · 0.45

Tested by

no test coverage detected