MCPcopy Create free account
hub / github.com/catboost/catboost / GetHomeDir

Function GetHomeDir

util/folder/dirut.cpp:496–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494}
495
496TString GetHomeDir() {
497 TString s(getenv("HOME"));
498 if (!s) {
499#ifndef _win32_
500 passwd* pw = nullptr;
501 s = getenv("USER");
502 if (s) {
503 pw = getpwnam(s.data());
504 } else {
505 pw = getpwuid(getuid());
506 }
507 if (pw) {
508 s = pw->pw_dir;
509 } else
510#endif
511 {
512 char* cur_dir = getcwd(nullptr, 0);
513 s = cur_dir;
514 free(cur_dir);
515 }
516 }
517 return s;
518}
519
520void MakeDirIfNotExist(const char* path, int mode) {
521 if (!NFs::MakeDirectory(path, NFs::EFilePermission(mode)) && !NFs::Exists(path)) {

Callers 1

resolvepathFunction · 0.85

Calls 3

getcwdFunction · 0.50
freeFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected