deprecate existsDir; use dirExists instead (#14884)
This commit is contained in:
parent
4f6acf24ff
commit
695154970d
14 changed files with 32 additions and 39 deletions
|
|
@ -1117,13 +1117,7 @@ proc fileExists*(filename: string): bool {.rtl, extern: "nos$1",
|
|||
var res: Stat
|
||||
return stat(filename, res) >= 0'i32 and S_ISREG(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)
|
||||
# {.deprecated: [existsFile: fileExists].} # pending bug #14819; this would avoid above mentioned issue
|
||||
|
||||
proc existsDir*(dir: string): bool {.rtl, extern: "nos$1", tags: [ReadDirEffect],
|
||||
proc dirExists*(dir: string): bool {.rtl, extern: "nos$1", tags: [ReadDirEffect],
|
||||
noNimJs.} =
|
||||
## Returns true if the directory `dir` exists. If `dir` is a file, false
|
||||
## is returned. Follows symlinks.
|
||||
|
|
@ -1150,7 +1144,7 @@ proc symlinkExists*(link: string): bool {.rtl, extern: "nos$1",
|
|||
##
|
||||
## See also:
|
||||
## * `fileExists proc <#fileExists,string>`_
|
||||
## * `existsDir proc <#existsDir,string>`_
|
||||
## * `dirExists proc <#dirExists,string>`_
|
||||
when defined(windows):
|
||||
when useWinUnicode:
|
||||
wrapUnary(a, getFileAttributesW, link)
|
||||
|
|
@ -1163,13 +1157,13 @@ proc symlinkExists*(link: string): bool {.rtl, extern: "nos$1",
|
|||
return lstat(link, res) >= 0'i32 and S_ISLNK(res.st_mode)
|
||||
|
||||
|
||||
proc dirExists*(dir: string): bool {.inline, noNimJs.} =
|
||||
## Alias for `existsDir proc <#existsDir,string>`_.
|
||||
##
|
||||
## See also:
|
||||
## * `fileExists proc <#fileExists,string>`_
|
||||
## * `symlinkExists proc <#symlinkExists,string>`_
|
||||
existsDir(dir)
|
||||
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 =
|
||||
|
|
@ -2026,7 +2020,7 @@ proc expandFilename*(filename: string): string {.rtl, extern: "nos$1",
|
|||
# way of retrieving the true filename
|
||||
for x in walkFiles(result):
|
||||
result = x
|
||||
if not fileExists(result) and not existsDir(result):
|
||||
if not fileExists(result) and not dirExists(result):
|
||||
# consider using: `raiseOSError(osLastError(), result)`
|
||||
raise newException(OSError, "file '" & result & "' does not exist")
|
||||
else:
|
||||
|
|
@ -2323,7 +2317,7 @@ proc existsOrCreateDir*(dir: string): bool {.rtl, extern: "nos$1",
|
|||
result = not rawCreateDir(dir)
|
||||
if result:
|
||||
# path already exists - need to check that it is indeed a directory
|
||||
if not existsDir(dir):
|
||||
if not dirExists(dir):
|
||||
raise newException(IOError, "Failed to create '" & dir & "'")
|
||||
|
||||
proc createDir*(dir: string) {.rtl, extern: "nos$1",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue