mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 01:44:37 +00:00
export normalizePathEnd (#13152)
This commit is contained in:
committed by
Andreas Rumpf
parent
e708d5de75
commit
51c072bd37
@@ -51,6 +51,8 @@
|
||||
and `typetraits.get` to get the ith element of a type tuple.
|
||||
- Added `typetraits.genericParams` to return a tuple of generic params from a generic instantiation
|
||||
|
||||
- Added `os.normalizePathEnd` for additional path sanitization.
|
||||
|
||||
## Library changes
|
||||
|
||||
- `asyncdispatch.drain` now properly takes into account `selector.hasPendingOperations`
|
||||
|
||||
@@ -103,9 +103,18 @@ proc normalizePathEnd(path: var string, trailingSep = false) =
|
||||
path = $DirSep
|
||||
|
||||
proc normalizePathEnd(path: string, trailingSep = false): string =
|
||||
## outplace overload
|
||||
runnableExamples:
|
||||
when defined(posix):
|
||||
assert normalizePathEnd("/lib//", trailingSep = true) == "/lib/"
|
||||
assert normalizePathEnd("lib//", trailingSep = false) == "lib"
|
||||
assert normalizePathEnd("", trailingSep = true) == "" # not / !
|
||||
result = path
|
||||
result.normalizePathEnd(trailingSep)
|
||||
|
||||
when (NimMajor, NimMinor) >= (1, 1):
|
||||
export normalizePathEnd
|
||||
|
||||
proc joinPath*(head, tail: string): string {.
|
||||
noSideEffect, rtl, extern: "nos$1".} =
|
||||
## Joins two directory names to one.
|
||||
|
||||
Reference in New Issue
Block a user