From 873baf773a669fad42069850bbfc95cd95e93e4f Mon Sep 17 00:00:00 2001 From: obijuan Date: Wed, 10 Feb 2016 11:07:00 +0100 Subject: [Icetime] PREFIX expansion for locating the chipdb files in the user home directory --- icetime/icetime.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'icetime/icetime.cc') 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) { -- cgit v1.2.3