Added absolute path support to options.findFile
This commit is contained in:
parent
6b00160938
commit
506b90cea8
2 changed files with 16 additions and 7 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue