summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnatoly Galiulin <galiulin.anatoly@gmail.com>2015-07-21 09:58:26 +0600
committerAnatoly Galiulin <galiulin.anatoly@gmail.com>2015-07-21 09:58:26 +0600
commit506b90cea87028f18ca66f5088274423c4e46202 (patch)
tree83a7e8b2132e6976e245b4086311cfc1d3aa23f7
parent6b001609384876e4421e3550ba91770fd2e2b52e (diff)
downloadNim-506b90cea87028f18ca66f5088274423c4e46202.tar.gz
Added absolute path support to options.findFile
-rw-r--r--compiler/options.nim13
-rw-r--r--tests/vm/tslurp.nim10
2 files changed, 16 insertions, 7 deletions
diff --git a/compiler/options.nim b/compiler/options.nim
index f312c877c..af1e21e60 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -330,13 +330,16 @@ proc rawFindFile2(f: string): string =
   result = ""
 
 proc findFile*(f: string): string {.procvar.} =
-  result = f.rawFindFile
-  if result.len == 0:
-    result = f.toLower.rawFindFile
+  if f.isAbsolute:
+    result = if f.existsFile: f else: ""
+  else:
+    result = f.rawFindFile
     if result.len == 0:
-      result = f.rawFindFile2
+      result = f.toLower.rawFindFile
       if result.len == 0:
-        result = f.toLower.rawFindFile2
+        result = f.rawFindFile2
+        if result.len == 0:
+          result = f.toLower.rawFindFile2
 
 proc findModule*(modulename, currentModule: string): string =
   # returns path to module
diff --git a/tests/vm/tslurp.nim b/tests/vm/tslurp.nim
index f9456ce6b..fc3dc6f0a 100644
--- a/tests/vm/tslurp.nim
+++ b/tests/vm/tslurp.nim
@@ -1,6 +1,12 @@
+import os
+
+template getScriptDir(): string =
+  parentDir(instantiationInfo(-1, true).filename)
 
 const
-  myRes = slurp"../../readme.txt"
+  relRes = slurp"../../readme.txt"
+  absRes = slurp(parentDir(parentDir(getScriptDir())) / "readme.txt")
   
-echo myRes
+echo relRes
+echo absRes