From 23f49985296a3594c2cf37fa08e0b3e882d5c9e4 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Fri, 29 Sep 2017 12:35:01 +0200 Subject: Add a function to surround filenames containing a space with quotes. --- lib/cUnix.ml | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/cUnix.ml') diff --git a/lib/cUnix.ml b/lib/cUnix.ml index 867f86a746..34fb660db4 100644 --- a/lib/cUnix.ml +++ b/lib/cUnix.ml @@ -14,6 +14,11 @@ type load_path = physical_path list let physical_path_of_string s = s let string_of_physical_path p = p +let escaped_string_of_physical_path p = + (* We assume a reasonable-enough path (typically utf8) and prevents + the presence of space; other escapings might be useful... *) + if String.contains p ' ' then "\"" ^ p ^ "\"" else p + let path_to_list p = let sep = Str.regexp (if Sys.os_type = "Win32" then ";" else ":") in Str.split sep p -- cgit v1.2.3