mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 09:54:49 +00:00
added os.tailDir proc
This commit is contained in:
@@ -621,6 +621,20 @@ proc parentDir*(path: string): string {.
|
||||
else:
|
||||
result = ""
|
||||
|
||||
proc tailDir*(path: string): string {.
|
||||
noSideEffect, rtl, extern: "nos$1".} =
|
||||
## Returns the tail part of `path`..
|
||||
##
|
||||
## | Example: ``tailDir("/usr/local/bin") == "local/bin"``.
|
||||
## | Example: ``tailDir("usr/local/bin/") == "local/bin"``.
|
||||
## | Example: ``tailDir("bin") == ""``.
|
||||
var q = 1
|
||||
if len(path) >= 1 and path[len(path)-1] in {DirSep, AltSep}: q = 2
|
||||
for i in 0..len(path)-q:
|
||||
if path[i] in {DirSep, AltSep}:
|
||||
return substr(path, i+1)
|
||||
result = ""
|
||||
|
||||
proc isRootDir*(path: string): bool {.
|
||||
noSideEffect, rtl, extern: "nos$1".} =
|
||||
## Checks whether a given `path` is a root directory
|
||||
|
||||
@@ -47,7 +47,8 @@ News
|
||||
|
||||
- The nre module has been added, providing a better interface to PCRE than
|
||||
re.
|
||||
- The ``expandSymlink`` procedure has been added to the ``os`` module.
|
||||
- The ``expandSymlink`` proc has been added to the ``os`` module.
|
||||
- The ``tailDir`` proc has been added to the ``os`` module.
|
||||
|
||||
Language Additions
|
||||
------------------
|
||||
|
||||
Reference in New Issue
Block a user