| 494 | } |
| 495 | |
| 496 | TString 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 | |
| 520 | void MakeDirIfNotExist(const char* path, int mode) { |
| 521 | if (!NFs::MakeDirectory(path, NFs::EFilePermission(mode)) && !NFs::Exists(path)) { |
no test coverage detected