diff options
-rw-r--r-- | lib/pure/os.nim | 16 | ||||
-rw-r--r-- | web/news.txt | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 6f8d923e3..f4796433d 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1645,6 +1645,22 @@ proc getTempDir*(): string {.rtl, extern: "nos$1", tags: [ReadEnvEffect].} = when defined(windows): return string(getEnv("TEMP")) & "\\" else: return "/tmp/" +proc expandSymlink*(symlinkPath: string): string = + ## Returns a string representing the path to which the symbolic link points. + ## + ## On Windows this is a noop, ``symlinkPath`` is simply returned. + when defined(windows): + result = symlinkPath + else: + result = newString(256) + var len = readlink(symlinkPath, result, 256) + if len < 0: + raiseOSError(osLastError()) + if len > 256: + result = newString(len+1) + len = readlink(symlinkPath, result, len) + setLen(result, len) + when defined(nimdoc): # Common forward declaration docstring block for parameter retrieval procs. proc paramCount*(): int {.tags: [ReadIOEffect].} = diff --git a/web/news.txt b/web/news.txt index 639ebe946..0e137a805 100644 --- a/web/news.txt +++ b/web/news.txt @@ -40,6 +40,7 @@ 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. Language Additions ------------------ |