summary refs log tree commit diff stats
path: root/lib/std/paths.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/paths.nim')
-rw-r--r--lib/std/paths.nim15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/std/paths.nim b/lib/std/paths.nim
index c29096982..664dedd31 100644
--- a/lib/std/paths.nim
+++ b/lib/std/paths.nim
@@ -1,4 +1,7 @@
 ## This module implements path handling.
+##
+## **See also:**
+## * `files module <files.html>`_ for file access
 
 import std/private/osseps
 export osseps
@@ -6,7 +9,7 @@ export osseps
 import std/envvars
 import std/private/osappdirs
 
-import pathnorm
+import std/[pathnorm, hashes, sugar, strutils]
 
 from std/private/ospaths2 import  joinPath, splitPath,
                                   ReadDirEffect, WriteDirEffect,
@@ -22,6 +25,16 @@ export ReadDirEffect, WriteDirEffect
 type
   Path* = distinct string
 
+func hash*(x: Path): Hash =
+  let x = x.string.dup(normalizePath)
+  if FileSystemCaseSensitive:
+    result = x.hash
+  else:
+    result = x.toLowerAscii.hash
+
+template `$`*(x: Path): string =
+  string(x)
+
 func `==`*(x, y: Path): bool {.inline.} =
   ## Compares two paths.
   ##