瀏覽代碼

document path functions

Dan Korostelev 9 年之前
父節點
當前提交
eac9b19537
共有 1 個文件被更改,包括 14 次插入4 次删除
  1. 14 4
      src/typing/common.ml

+ 14 - 4
src/typing/common.ml

@@ -1125,14 +1125,24 @@ let find_file ctx f =
 		| None -> raise Not_found
 		| Some f -> f)
 
-let get_full_path f = try Extc.get_full_path f with _ -> f
-
 let is_windows = Sys.os_type = "Win32" || Sys.os_type = "Cygwin"
-
 let path_sep = if is_windows then "\\" else "/"
 
-let unique_full_path = if is_windows then (fun f -> String.lowercase (get_full_path f)) else get_full_path
+(** Returns absolute path for given path `f`.
+    Doesn't fix path case on Windows. *)
+let get_full_path f = try Extc.get_full_path f with _ -> f
+
+(** Returns absolute path guaranteed to be the same for different letter case.
+    For use where equality comparison is required, lowercases the path on Windows *)
+let unique_full_path =
+	if is_windows then
+		(fun f -> String.lowercase (get_full_path f))
+	else
+		get_full_path
 
+(** On Windows: returns absolute path with proper case (drive letter upper-cased),
+    unless there's an error, then is a no-op. On non-Windows is a no-op.
+    ¯\_(ツ)_/¯ *)
 let get_real_path p =
 	try
 		Extc.get_real_path p