diff options
author | Joseph Henry <josephjah@gmail.com> | 2017-06-25 20:20:30 -0700 |
---|---|---|
committer | Joseph Henry <josephjah@gmail.com> | 2017-06-25 20:20:30 -0700 |
commit | c61440efea086ab5c9acb515604aac34d84b13cb (patch) | |
tree | 79232ea7b43a4e6693bfcafe21f1cdd23c8b9c87 /osdep | |
parent | 7bc9666aacc693105e6ad103610ee949604ed5c2 (diff) | |
download | infinitytier-c61440efea086ab5c9acb515604aac34d84b13cb.tar.gz infinitytier-c61440efea086ab5c9acb515604aac34d84b13cb.zip |
Detect platformDefaultHomePath on QNAP systems
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/OSUtils.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/osdep/OSUtils.cpp b/osdep/OSUtils.cpp index b7fce982..46c1a8ae 100644 --- a/osdep/OSUtils.cpp +++ b/osdep/OSUtils.cpp @@ -363,6 +363,24 @@ std::vector<std::string> OSUtils::split(const char *s,const char *const sep,cons std::string OSUtils::platformDefaultHomePath() { +#ifdef __QNAP__ + char *cmd = "/sbin/getcfg ZeroTier Install_Path -f /etc/config/qpkg.conf"; + char buf[128]; + FILE *fp; + if ((fp = popen(cmd, "r")) == NULL) { + printf("Error opening pipe!\n"); + return NULL; + } + while (fgets(buf, 128, fp) != NULL) { } + if(pclose(fp)) { + printf("Command not found or exited with error status\n"); + return NULL; + } + std::string homeDir = std::string(buf); + homeDir.erase(std::remove(homeDir.begin(), homeDir.end(), '\n'), homeDir.end()); + return homeDir; +#endif + #ifdef __UNIX_LIKE__ #ifdef __APPLE__ |