Skip to content

Commit

Permalink
Add hints regarding expandTilde and example
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Ceratto committed Oct 15, 2018
1 parent 0c04da6 commit 54aa846
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/pure/os.nim
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ proc expandFilename*(filename: string): string {.rtl, extern: "nos$1",
tags: [ReadDirEffect].} =
## Returns the full (`absolute`:idx:) path of an existing file `filename`,
## raises OSError in case of an error. Follows symlinks.
##
## To expand tilde ("~") use `expandTilde`:idx:
when defined(windows):
var bufsize = MAX_PATH.int32
when useWinUnicode:
Expand Down Expand Up @@ -357,6 +359,8 @@ proc normalizePath*(path: var string) {.rtl, extern: "nos$1", tags: [].} =
##
## Warning: URL-encoded and Unicode attempts at directory traversal are not detected.
## Triple dot is not handled.
##
## To expand tilde ("~") use `expandTilde`:idx:
let isAbs = isAbsolute(path)
var stack: seq[string] = @[]
for p in split(path, {DirSep}):
Expand Down Expand Up @@ -385,6 +389,8 @@ proc normalizePath*(path: var string) {.rtl, extern: "nos$1", tags: [].} =

proc normalizedPath*(path: string): string {.rtl, extern: "nos$1", tags: [].} =
## Returns a normalized path for the current OS. See `<#normalizePath>`_
runnableExamples:
doAssert normalizedPath("/a/b/../../foo") == "/foo"
result = path
normalizePath(result)

Expand Down

0 comments on commit 54aa846

Please sign in to comment.