10 #include <sys/ioctl.h>
20 if(command ==
""){
return "";}
21 FILE * fp = popen(command.c_str(),
"r");
22 if(fp == NULL){
return "";}
35 if(command ==
""){
return -1;}
36 FILE * fp = popen(command.c_str(),
"r");
37 if(fp == NULL){
return -1;}
52 if((onlyLogOnFail && !b) || !onlyLogOnFail){
69 std::chrono::time_point<std::chrono::steady_clock> now = std::chrono::steady_clock::now();
70 auto duration = now.time_since_epoch();
71 auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
72 return nanoseconds.count();
102 std::tm* now_tm = std::gmtime(¤tTime);
104 std::strftime(buf, 42,
"%Y/%m/%d : %X", now_tm);
113 std::tm* now_tm = std::gmtime(¤tTime);
115 std::strftime(buf, 42,
"%Y/%m/%d-%X", now_tm);
125 getlogin_r((
char*)str.data(), str.size() - 1lu);
135 ioctl(0, TIOCGWINSZ, &w);
144 ioctl(0, TIOCGWINSZ, &w);
PString phoenix_getFileContent(FILE *fp)
Get the content of a file.
Path of a directory or a file.
bool saveFileContent(const PString &content) const
Save a PString in a file.
PString phoenix_getDateCompact()
Get the current date.
time_t phoenix_getTime()
Get the current time of the program.
double phoenix_getClockSec()
Get current time.
short unsigned int phoenix_getNbRowTerminal()
Get the number of rows of the terminal.
short unsigned int phoenix_getNbColTerminal()
Get the number of columns of the terminal.
time_t phoenix_getClockNs()
Get current time in nanosecond since the starting of the CPU (steady_clock)
time_t phoenix_getClock()
Get current time.
PString phoenix_getDate()
Get the current date.
PString phoenix_popen(const PString &command)
Execute the given command and returns the output of this command.
PString phoenix_whoami()
Get the name of the current user.