diff options
author | Jesús Arroyo Torrens <jesus.jkhlg@gmail.com> | 2016-08-23 21:17:05 +0200 |
---|---|---|
committer | Jesús Arroyo Torrens <jesus.jkhlg@gmail.com> | 2016-08-23 21:30:00 +0200 |
commit | fb2b83a19b6466b18892be348f90de2d6c2d0a58 (patch) | |
tree | d523d8859bc1024a9eb6bebb94e6eb824c2ad097 | |
parent | 12b2295c9087d94b75e374bb205ae4d76cf17e2f (diff) | |
download | icestorm-fb2b83a19b6466b18892be348f90de2d6c2d0a58.tar.gz icestorm-fb2b83a19b6466b18892be348f90de2d6c2d0a58.tar.bz2 icestorm-fb2b83a19b6466b18892be348f90de2d6c2d0a58.zip |
icetime: support PREFIX expansion for win32
-rw-r--r-- | icetime/icetime.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/icetime/icetime.cc b/icetime/icetime.cc index affc56d..252d820 100644 --- a/icetime/icetime.cc +++ b/icetime/icetime.cc @@ -276,8 +276,24 @@ void read_chipdb() { char buffer[1024]; - if (PREFIX[0] == '~' && PREFIX[1] == '/') - snprintf(buffer, 1024, "%s%s/share/icebox/chipdb-%s.txt", getenv("HOME"), PREFIX+1, config_device.c_str()); + if (PREFIX[0] == '~' && PREFIX[1] == '/') { + std::string homedir; +#ifdef _WIN32 + if (getenv("USERPROFILE") != nullptr) { + homedir += getenv("USERPROFILE"); + } + else { + if (getenv("HOMEDRIVE") != nullptr && + getenv("HOMEPATH") != nullptr) { + homedir += getenv("HOMEDRIVE"); + homedir += getenv("HOMEPATH"); + } + } +#else + homedir += getenv("HOME"); +#endif + snprintf(buffer, 1024, "%s%s/share/icebox/chipdb-%s.txt", homedir.c_str(), PREFIX+1, config_device.c_str()); + } else snprintf(buffer, 1024, "%s/share/icebox/chipdb-%s.txt", PREFIX, config_device.c_str()); |