Merge branch 'findspeed' of https://github.com/genotrance/nimterop into findspeed
This commit is contained in:
commit
5150d19600
1 changed files with 7 additions and 5 deletions
|
|
@ -264,8 +264,10 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex =
|
||||||
cmd =
|
cmd =
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
"nimgrep --filenames --oneline --nocolor $1 $2 $3"
|
"nimgrep --filenames --oneline --nocolor $1 $2 $3"
|
||||||
else:
|
elif defined(linux):
|
||||||
"find $3 $1 -regextype egrep -regex $2"
|
"find $3 $1 -regextype egrep -regex $2"
|
||||||
|
elif defined(osx):
|
||||||
|
"find -E $3 $1 -regex $2"
|
||||||
|
|
||||||
recursive = ""
|
recursive = ""
|
||||||
|
|
||||||
|
|
@ -281,7 +283,7 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex =
|
||||||
dir = dir / file.parentDir()
|
dir = dir / file.parentDir()
|
||||||
file = file.extractFilename
|
file = file.extractFilename
|
||||||
|
|
||||||
cmd = cmd % [recursive, (".*[\\/]" & file & "$").quoteShell, dir.sanitizePath]
|
cmd = cmd % [recursive, (".*[\\\\/]" & file & "$").quoteShell, dir.sanitizePath]
|
||||||
|
|
||||||
let
|
let
|
||||||
(files, ret) = gorgeEx(cmd)
|
(files, ret) = gorgeEx(cmd)
|
||||||
|
|
@ -289,14 +291,14 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex =
|
||||||
for line in files.splitLines():
|
for line in files.splitLines():
|
||||||
let f =
|
let f =
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
if ":" in line:
|
if ": " in line:
|
||||||
line.split(":", maxsplit = 1)[0]
|
line.split(": ", maxsplit = 1)[1]
|
||||||
else:
|
else:
|
||||||
""
|
""
|
||||||
else:
|
else:
|
||||||
line
|
line
|
||||||
|
|
||||||
if (f.len != 0 and result.len == 0 or result.len > f.len):
|
if (f.len != 0 and (result.len == 0 or result.len > f.len)):
|
||||||
result = f
|
result = f
|
||||||
if first: break
|
if first: break
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue