expand ~
This commit is contained in:
parent
3c82bdfa51
commit
fdbe9cfb84
|
@ -17,18 +17,28 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
|
||||||
|
static const char* expand_like_shell(const char *path) {
|
||||||
|
static __thread char buf[TSDB_FILENAME_LEN];
|
||||||
|
buf[0] = '\0';
|
||||||
|
wordexp_t we;
|
||||||
|
if (wordexp(path, &we, 0)) return "/tmp/taosd";
|
||||||
|
if (sizeof(buf)<=snprintf(buf, sizeof(buf), "%s", we.we_wordv[0])) return "/tmp/taosd";
|
||||||
|
wordfree(&we);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
void osInit() {
|
void osInit() {
|
||||||
if (configDir[0] == 0) {
|
if (configDir[0] == 0) {
|
||||||
strcpy(configDir, "/etc/taos");
|
strcpy(configDir, expand_like_shell("~/TDengine/cfg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(tsVnodeDir, "");
|
strcpy(tsVnodeDir, "");
|
||||||
strcpy(tsDnodeDir, "");
|
strcpy(tsDnodeDir, "");
|
||||||
strcpy(tsMnodeDir, "");
|
strcpy(tsMnodeDir, "");
|
||||||
|
|
||||||
strcpy(tsDataDir, "/tmp/taosd/data");
|
strcpy(tsDataDir, expand_like_shell("~/TDengine/data"));
|
||||||
strcpy(tsLogDir, "/tmp/taosd/log");
|
strcpy(tsLogDir, expand_like_shell("~/TDengine/log"));
|
||||||
strcpy(tsScriptDir, "/etc/taos");
|
strcpy(tsScriptDir, expand_like_shell("~/TDengine/cfg"));
|
||||||
|
|
||||||
strcpy(tsOsName, "Darwin");
|
strcpy(tsOsName, "Darwin");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue