mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-19 23:41:29 +00:00
Merge pull request #3137 from vegansk/findFile_absolute
Added absolute path support to options.findFile
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user