MCPcopy Create free account
hub / github.com/cinder/Cinder / getHomeDirectory

Method getHomeDirectory

src/cinder/app/linux/PlatformLinux.cpp:374–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372}
373
374fs::path PlatformLinux::getHomeDirectory() const
375{
376 fs::path result;
377
378 const char *homeDir = getenv( "HOME" );
379 if( nullptr == homeDir ) {
380 long int len = sysconf( _SC_GETPW_R_SIZE_MAX );
381 if( -1 == len ) {
382 len = 1024;
383 }
384 std::vector<char> buf( len );
385
386 struct passwd pwd = {};
387 struct passwd *pwdPtr = nullptr;
388 int error = 0;
389
390 while( ERANGE == ( error = getpwuid_r( getuid(), &pwd, buf.data(), buf.size(), &pwdPtr ) ) ) {
391 buf.resize( 2*buf.size() );
392 // Bail if the size becomes too big
393 if( buf.size() >= 65536 ) {
394 error = ERANGE;
395 break;
396 }
397 }
398
399 if( 0 == error ) {
400 result = fs::path( pwd.pw_dir );
401 }
402 }
403 else {
404 result = fs::path( homeDir );
405 }
406
407 return result;
408}
409
410fs::path PlatformLinux::getDocumentsDirectory() const
411{

Callers

nothing calls this directly

Calls 3

dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected