Support ~ for home directory
authorBen Widawsky <ben@bwidawsk.net>
Mon, 17 Jun 2019 21:45:11 +0000 (14:45 -0700)
committerBen Widawsky <ben@bwidawsk.net>
Tue, 18 Jun 2019 21:38:40 +0000 (14:38 -0700)
This is tested on Linux only

v2:
Wrap functioanlity in ifndef _WIN32 (eddiehung)
Find '~/' instead of '~' (cliffordwolf)

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
kernel/yosys.cc

index 377572fc2984243a2ede59d2e35af34a7fa27b8d..94d6d675f968ff24a2e205e24c39096a955a14ae 100644 (file)
@@ -651,6 +651,10 @@ void rewrite_filename(std::string &filename)
                filename = filename.substr(1, GetSize(filename)-2);
        if (filename.substr(0, 2) == "+/")
                filename = proc_share_dirname() + filename.substr(2);
+#ifndef _WIN32
+       if (filename.substr(0, 2) == "~/")
+               filename = filename.replace(0, 1, getenv("HOME"));
+#endif
 }
 
 #ifdef YOSYS_ENABLE_TCL