add get_home_directory function
This commit is contained in:
parent
0b287f755b
commit
e413a7d69d
3 changed files with 17 additions and 0 deletions
|
@ -8,6 +8,7 @@ raven_dep = dependency('raven')
|
|||
|
||||
executable(
|
||||
'filemanager',
|
||||
'./src/Dirs.cpp',
|
||||
'./src/FileButton.cpp',
|
||||
'./src/DirectoryView.cpp',
|
||||
'./src/TopBar.cpp',
|
||||
|
|
11
src/Dirs.cpp
Normal file
11
src/Dirs.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "Dirs.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
std::filesystem::path get_home_directory() {
|
||||
auto home_env = std::getenv("HOME");
|
||||
if (!home_env || !std::filesystem::exists(home_env)) {
|
||||
return "/";
|
||||
}
|
||||
return home_env;
|
||||
}
|
5
src/Dirs.hpp
Normal file
5
src/Dirs.hpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
std::filesystem::path get_home_directory();
|
Loading…
Reference in a new issue