summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-08-19 01:46:24 +0200
committerAraq <rumpf_a@web.de>2011-08-19 01:46:24 +0200
commitc7b130b4e2b5350c8b48cdbbef35cd42e773f67f (patch)
treeed6ecc256628287f933bfaa956a455ef202e6e7f /lib/pure
parent257b16ca34af4695a2c8881c976f5fe343fe51ed (diff)
downloadNim-c7b130b4e2b5350c8b48cdbbef35cd42e773f67f.tar.gz
implemented --nimcache config option; big clean up of magic words
Diffstat (limited to 'lib/pure')
-rwxr-xr-xlib/pure/os.nim15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index f33950376..feb2de977 100755
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -512,6 +512,21 @@ proc cmpPaths*(pathA, pathB: string): int {.
   else:
     result = cmpIgnoreCase(pathA, pathB)
 
+proc isAbsolute*(path: string): bool {.rtl, noSideEffect, extern: "nos$1".} =
+  ## Checks whether a given path is absolute.
+  ##
+  ## on Windows, network paths are considered absolute too.
+  var len = len(path)
+  when doslike:
+    result = (len > 1 and path[0] in {'/', '\\'}) or
+             (len > 2 and path[0] in Letters and path[1] == ':')
+  elif defined(macos):
+    result = len > 0 and path[0] != ':'
+  elif defined(RISCOS):
+    result = path[0] == '$'
+  elif defined(posix):
+    result = path[0] == '/'
+
 proc sameFile*(path1, path2: string): bool {.rtl, extern: "nos$1".} =
   ## Returns True if both pathname arguments refer to the same file or
   ## directory (as indicated by device number and i-node number).