Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
lnx_utils.h File Reference
#include <fcntl.h>
#include <filesystem>
#include <grp.h>
#include <misc/gen/TStrings.h>
#include <misc/gen/system.h>
#include <misc/global.h>
#include <pwd.h>
Include dependency graph for lnx_utils.h:

Go to the source code of this file.

Classes

struct  sf::passwd_t
 Extends struct passwd and auto allocates needed memory. Used as a result type with auto memory cleanup . More...
 
struct  sf::group_t
 

Namespaces

namespace  sf
 

Typedefs

typedef struct stat sf::stat_t
 Easier typename for 'struct stat'.
 
typedef struct passwd sf::passwd_type
 
typedef struct group sf::group_type
 

Functions

_MISC_FUNC bool sf::kb_hit ()
 
_MISC_FUNC pid_t sf::gettid () noexcept
 
_MISC_FUNC bool sf::getFiles (strings &files, const std::string &directory, const std::string &wildcard)
 
_MISC_FUNC bool sf::file_write (const char *path, const void *buf, size_t sz, bool append=false)
 Writes a buffer to a filepath.
 
bool sf::file_write (const std::string &path, const void *buf, size_t sz, bool append=false)
 Writes a character buffer to file.
 
bool sf::file_write (const std::string &path, const std::string &s, bool append=false)
 Writes a std::string to file.
 
_MISC_FUNC std::filesystem::path sf::file_fd_path (int fd)
 
_MISC_FUNC bool sf::file_stat (const std::string &path, stat_t &_stat)
 Same as stat() but using a std::string.
 
_MISC_FUNC std::string sf::time_format (const struct tm *time_info, const char *format=nullptr)
 Formats the time to the given format.
 
_MISC_FUNC std::string sf::time_format (time_t time=-1, const char *format=nullptr, bool gm_time=false)
 Formats the time to the given format.
 
_MISC_FUNC time_t sf::time_str2time (const std::string &str, const char *format=nullptr, bool gm_time=false)
 Gets the unix time from the passed string in the format that was passed.
 
_MISC_FUNC time_t sf::time_mktime (struct tm *tm, bool gm_time=false)
 Same as mktime().
 
_MISC_FUNC bool sf::file_mkdir (const char *path, __mode_t mode=0755)
 Makes all directories recursively in the path.
 
bool sf::file_mkdir (const std::string &path, __mode_t mode=0755)
 Makes all directories recursively in the path.
 
bool sf::proc_getpwnam (std::string name, passwd_t &pwd)
 
bool sf::proc_getpwuid (uid_t uid, passwd_t &pwd)
 
void sf::proc_setuid (uid_t uid)
 
void sf::proc_seteuid (uid_t uid)
 
_MISC_FUNC bool sf::proc_getgrnam (const std::string &name, group_t &grp)
 
_MISC_FUNC bool sf::proc_getgrgid (gid_t gid, group_t &grp)
 
_MISC_FUNC void sf::proc_setgid (gid_t gid)
 
_MISC_FUNC void sf::proc_setegid (gid_t gid)
 
_MISC_FUNC void sf::proc_setfsuid (uid_t uid)
 
_MISC_FUNC void sf::proc_setfsgid (gid_t gid)
 
int _MISC_FUNC sf::siginterrupt (int sig, int flag)
 Replacement for deprecated 'siginterrupt' function. Returns EINVAL when the sig argument is not a valid signal number otherwise zero.