remove private checkSymlink (redundant with symlinkExists) (#16785)
This commit is contained in:
parent
d2b218b80a
commit
aca97250ea
1 changed files with 12 additions and 16 deletions
|
|
@ -1151,26 +1151,13 @@ proc symlinkExists*(link: string): bool {.rtl, extern: "nos$1",
|
||||||
else:
|
else:
|
||||||
var a = getFileAttributesA(link)
|
var a = getFileAttributesA(link)
|
||||||
if a != -1'i32:
|
if a != -1'i32:
|
||||||
|
# xxx see: bug #16784 (bug9); checking `IO_REPARSE_TAG_SYMLINK`
|
||||||
|
# may also be needed.
|
||||||
result = (a and FILE_ATTRIBUTE_REPARSE_POINT) != 0'i32
|
result = (a and FILE_ATTRIBUTE_REPARSE_POINT) != 0'i32
|
||||||
else:
|
else:
|
||||||
var res: Stat
|
var res: Stat
|
||||||
return lstat(link, res) >= 0'i32 and S_ISLNK(res.st_mode)
|
return lstat(link, res) >= 0'i32 and S_ISLNK(res.st_mode)
|
||||||
|
|
||||||
|
|
||||||
when not defined(nimscript):
|
|
||||||
when not defined(js): # `noNimJs` doesn't work with templates, this should improve.
|
|
||||||
template existsFile*(args: varargs[untyped]): untyped {.deprecated: "use fileExists".} =
|
|
||||||
fileExists(args)
|
|
||||||
template existsDir*(args: varargs[untyped]): untyped {.deprecated: "use dirExists".} =
|
|
||||||
dirExists(args)
|
|
||||||
# {.deprecated: [existsFile: fileExists].} # pending bug #14819; this would avoid above mentioned issue
|
|
||||||
|
|
||||||
when not defined(windows) and not weirdTarget:
|
|
||||||
proc checkSymlink(path: string): bool =
|
|
||||||
var rawInfo: Stat
|
|
||||||
if lstat(path, rawInfo) < 0'i32: result = false
|
|
||||||
else: result = S_ISLNK(rawInfo.st_mode)
|
|
||||||
|
|
||||||
const
|
const
|
||||||
maxSymlinkLen = 1024
|
maxSymlinkLen = 1024
|
||||||
ExeExts* = ## Platform specific file extension for executables.
|
ExeExts* = ## Platform specific file extension for executables.
|
||||||
|
|
@ -1213,7 +1200,7 @@ proc findExe*(exe: string, followSymlinks: bool = true;
|
||||||
if fileExists(x):
|
if fileExists(x):
|
||||||
when not defined(windows):
|
when not defined(windows):
|
||||||
while followSymlinks: # doubles as if here
|
while followSymlinks: # doubles as if here
|
||||||
if x.checkSymlink:
|
if x.symlinkExists:
|
||||||
var r = newString(maxSymlinkLen)
|
var r = newString(maxSymlinkLen)
|
||||||
var len = readlink(x, r, maxSymlinkLen)
|
var len = readlink(x, r, maxSymlinkLen)
|
||||||
if len < 0:
|
if len < 0:
|
||||||
|
|
@ -3310,3 +3297,12 @@ func isValidFilename*(filename: string, maxLen = 259.Positive): bool {.since: (1
|
||||||
find(f.name, invalidFilenameChars) != -1): return false
|
find(f.name, invalidFilenameChars) != -1): return false
|
||||||
for invalid in invalidFilenames:
|
for invalid in invalidFilenames:
|
||||||
if cmpIgnoreCase(f.name, invalid) == 0: return false
|
if cmpIgnoreCase(f.name, invalid) == 0: return false
|
||||||
|
|
||||||
|
# deprecated declarations
|
||||||
|
when not defined(nimscript):
|
||||||
|
when not defined(js): # `noNimJs` doesn't work with templates, this should improve.
|
||||||
|
template existsFile*(args: varargs[untyped]): untyped {.deprecated: "use fileExists".} =
|
||||||
|
fileExists(args)
|
||||||
|
template existsDir*(args: varargs[untyped]): untyped {.deprecated: "use dirExists".} =
|
||||||
|
dirExists(args)
|
||||||
|
# {.deprecated: [existsFile: fileExists].} # pending bug #14819; this would avoid above mentioned issue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue