summary refs log tree commit diff stats
path: root/lib/std/paths.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-05-31 17:07:48 +0800
committerGitHub <noreply@github.com>2024-05-31 11:07:48 +0200
commitcdfc886f88cc95a8dc05e2211d1030b146a521f5 (patch)
treebb0cbb796b2dfeadb4d4b7f7aafcf142a91c2aa3 /lib/std/paths.nim
parentc1f31cedbb81c4ba6d82d85d6499dd812e7c6ab8 (diff)
downloadNim-cdfc886f88cc95a8dc05e2211d1030b146a521f5.tar.gz
fixes #23663; Add hash() for Path (#23664)
fixes #23663
Diffstat (limited to 'lib/std/paths.nim')
-rw-r--r--lib/std/paths.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/std/paths.nim b/lib/std/paths.nim
index ac2e5cea4..664dedd31 100644
--- a/lib/std/paths.nim
+++ b/lib/std/paths.nim
@@ -9,7 +9,7 @@ export osseps
 import std/envvars
 import std/private/osappdirs
 
-import std/pathnorm
+import std/[pathnorm, hashes, sugar, strutils]
 
 from std/private/ospaths2 import  joinPath, splitPath,
                                   ReadDirEffect, WriteDirEffect,
@@ -25,6 +25,13 @@ 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)