diff options
author | Eric Doughty-Papassideris <eric.doughty@gmail.com> | 2012-01-21 16:49:45 +0100 |
---|---|---|
committer | Eric Doughty-Papassideris <eric.doughty@gmail.com> | 2012-01-21 16:49:45 +0100 |
commit | 374a4cdb8ae2c3d7d4789e079bbf1cb542acb4eb (patch) | |
tree | 6182893ef4ca914e31f925b8134e629cdee4f7da /lib | |
parent | 1602e8e2f4fe6b26d37ad570389ade446e593a37 (diff) | |
download | Nim-374a4cdb8ae2c3d7d4789e079bbf1cb542acb4eb.tar.gz |
On Mac OS X 10.5, realpath does not allocate the buffer on its own
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/pure/os.nim | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 44811589a..a57b45b32 100755 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -151,6 +151,10 @@ else: # UNIX-like operating system ScriptExt* = "" DynlibFormat* = "lib$1.so" +when defined(macosx): + var + pathMax {.importc: "PATH_MAX", header: "<stdlib.h>".}: cint + const ExtSep* = '.' ## The character which separates the base filename from the extension; @@ -505,6 +509,12 @@ proc expandFilename*(filename: string): string {.rtl, extern: "nos$1".} = var L = GetFullPathNameA(filename, 3072'i32, result, unused) if L <= 0'i32 or L >= 3072'i32: OSError() setLen(result, L) + when defined(macosx): + # On Mac OS X 10.5, realpath does not allocate the buffer on its own + var pathBuffer: cstring = newString(pathMax) + var resultBuffer = realpath(filename, pathBuffer) + if resultBuffer == nil: OSError() + result = $resultBuffer else: var res = realpath(filename, nil) if res == nil: OSError() |