Added absolute path support to options.findFile

This commit is contained in:
Anatoly Galiulin 2015-07-21 09:58:26 +06:00
commit 506b90cea8
2 changed files with 16 additions and 7 deletions

View file

@ -330,6 +330,9 @@ proc rawFindFile2(f: string): string =
result = "" result = ""
proc findFile*(f: string): string {.procvar.} = proc findFile*(f: string): string {.procvar.} =
if f.isAbsolute:
result = if f.existsFile: f else: ""
else:
result = f.rawFindFile result = f.rawFindFile
if result.len == 0: if result.len == 0:
result = f.toLower.rawFindFile result = f.toLower.rawFindFile

View file

@ -1,6 +1,12 @@
import os
template getScriptDir(): string =
parentDir(instantiationInfo(-1, true).filename)
const const
myRes = slurp"../../readme.txt" relRes = slurp"../../readme.txt"
absRes = slurp(parentDir(parentDir(getScriptDir())) / "readme.txt")
echo myRes echo relRes
echo absRes