Added absolute path support to options.findFile

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

View File

@@ -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

View File

@@ -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