use github repo as central
This commit is contained in:
30
test/core/utils.h
Normal file
30
test/core/utils.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
class utUtils {
|
||||
public:
|
||||
void get_dir_exec(char* dir, char* exec) {
|
||||
char* filename = nullptr;
|
||||
if (readlink("/proc/self/exe", dir, 1024) < 0) {
|
||||
dir[0] = '\0';
|
||||
return;
|
||||
}
|
||||
filename = strrchr(dir, '/');
|
||||
if (filename == nullptr) {
|
||||
dir[0] = '\0';
|
||||
return;
|
||||
}
|
||||
++filename;
|
||||
if (exec) {
|
||||
sprintf(exec, "%s", filename);
|
||||
}
|
||||
|
||||
*filename = '\0';
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user