2023-10-25 07:43:36 +03:00
|
|
|
#pragma once
|
|
|
|
///@file
|
|
|
|
|
|
|
|
#include "types.hh"
|
|
|
|
|
2023-09-03 00:35:16 +03:00
|
|
|
#ifndef _WIN32
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
2023-10-25 07:43:36 +03:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
std::string getUserName();
|
|
|
|
|
2023-09-03 00:35:16 +03:00
|
|
|
#ifndef _WIN32
|
2023-10-25 07:43:36 +03:00
|
|
|
/**
|
|
|
|
* @return the given user's home directory from /etc/passwd.
|
|
|
|
*/
|
|
|
|
Path getHomeOf(uid_t userId);
|
2023-09-03 00:35:16 +03:00
|
|
|
#endif
|
2023-10-25 07:43:36 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return $HOME or the user's home directory from /etc/passwd.
|
|
|
|
*/
|
|
|
|
Path getHome();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return $XDG_CACHE_HOME or $HOME/.cache.
|
|
|
|
*/
|
|
|
|
Path getCacheDir();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return $XDG_CONFIG_HOME or $HOME/.config.
|
|
|
|
*/
|
|
|
|
Path getConfigDir();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the directories to search for user configuration files
|
|
|
|
*/
|
|
|
|
std::vector<Path> getConfigDirs();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return $XDG_DATA_HOME or $HOME/.local/share.
|
|
|
|
*/
|
|
|
|
Path getDataDir();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return $XDG_STATE_HOME or $HOME/.local/state.
|
|
|
|
*/
|
|
|
|
Path getStateDir();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create the Nix state directory and return the path to it.
|
|
|
|
*/
|
|
|
|
Path createNixStateDir();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform tilde expansion on a path, replacing tilde with the user's
|
|
|
|
* home directory.
|
|
|
|
*/
|
|
|
|
std::string expandTilde(std::string_view path);
|
|
|
|
|
2024-03-29 21:40:56 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the current user UID 0 on Unix?
|
2023-09-03 00:35:16 +03:00
|
|
|
*
|
|
|
|
* Currently always false on Windows, but that may change.
|
2024-03-29 21:40:56 +02:00
|
|
|
*/
|
|
|
|
bool isRootUser();
|
|
|
|
|
2023-10-25 07:43:36 +03:00
|
|
|
}
|