diff options
author | obijuan <juan@iearobotics.com> | 2016-02-10 11:07:00 +0100 |
---|---|---|
committer | obijuan <juan@iearobotics.com> | 2016-02-10 11:07:00 +0100 |
commit | 873baf773a669fad42069850bbfc95cd95e93e4f (patch) | |
tree | 63883f1e4b62bc9ee507e73f6ebcf48b5776ab7a /icetime | |
parent | b49d2d3e78cd6bd9ce4d63781c80cefd2b8853e4 (diff) | |
download | icestorm-873baf773a669fad42069850bbfc95cd95e93e4f.tar.gz icestorm-873baf773a669fad42069850bbfc95cd95e93e4f.tar.bz2 icestorm-873baf773a669fad42069850bbfc95cd95e93e4f.zip |
[Icetime] PREFIX expansion for locating the chipdb files in the user home directory
Diffstat (limited to 'icetime')
-rw-r--r-- | icetime/icetime.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/icetime/icetime.cc b/icetime/icetime.cc index 15cea2c..dc8c436 100644 --- a/icetime/icetime.cc +++ b/icetime/icetime.cc @@ -265,7 +265,17 @@ void read_config() void read_chipdb() { char buffer[1024]; - snprintf(buffer, 1024, PREFIX "/share/icebox/chipdb-%s.txt", config_device.c_str()); + char path[1024]; + + //-- If the PREFIX initial character is ~ expand it the + //-- home directory + if (strlen(PREFIX)>0 && PREFIX[0]=='~') + snprintf(path, 1024, "%s%s", getenv("HOME"), &PREFIX[1]); + else + snprintf(path, 1024, "%s", PREFIX); + + //-- Chipdb file with full path + snprintf(buffer, 1024, "%s/share/icebox/chipdb-%s.txt", path, config_device.c_str()); FILE *fdb = fopen(buffer, "r"); if (fdb == nullptr) { |