Skip to content

Commit

Permalink
icetime: support PREFIX expansion for win32
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesus89 committed Aug 23, 2016
1 parent 12b2295 commit fb2b83a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions icetime/icetime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit fb2b83a

Please sign in to comment.