8 let convert_compress_slashes s
=
9 let l = String.length s
in
10 let t = String.create
l in
11 let rec loop prev_slash i j
=
25 loop true (succ i
) (succ j
)
30 loop false (succ i
) (succ j
)
33 let rl = loop false 0 0 in
34 if rl = String.length
t
40 let convert_slashes = convert_compress_slashes
42 let find_unix_path path
=
43 let dirname = Filename.dirname path
in
46 Format.eprintf
"find_unix_path: %S - %S %b@.@."
47 path
dirname (Sys.file_exists
dirname);
48 if not
(Sys.file_exists
dirname)
52 if not
(Sys.file_exists path
)
54 let basename = Filename.basename path
in
55 let names = Sys.readdir
dirname in
58 Format.eprintf
"readdir: %S@." dirname;
59 let lowercase_name = String.lowercase
basename in
60 let find_string_lower target
names =
61 let len = Array.length
names in
62 let rec finder index
=
67 let name = names.(index
) in
68 let lowercase_name = String.lowercase
name in
69 if lowercase_name = target
77 match (find_string_lower lowercase_name names) with
81 Path
(Filename.concat
dirname name)
88 Format.eprintf
"find(%S)@." path
;
89 let res = find_unix_path path
in
92 let dirname = Filename.dirname path
in
93 let res = find dirname in
96 | Path correct_dirname
->
97 let basename = Filename.basename path
in
98 let path = Filename.concat correct_dirname
basename in
107 let len = String.length s
in
108 let rec collect list pos
=
114 | ' '
| '
\t'
| '
\n'
| '
\r'
->
115 collect list
(succ pos
)
119 String.index_from s pos '"'
121 prerr_string
"Path.split: mismatched quote ";
122 prerr_string
(String.escaped s
);
123 prerr_string
" pos:";
128 let s = String.sub
s pos
(endpos - pos
) in
129 collect (s :: list
) endpos
133 String.index_from
s pos ' '
137 let s = String.sub
s pos
(endpos - pos
) in
138 collect (s :: list
) endpos
144 if not
Wine.native
|| !Wine.native_convert_slashes
146 convert_slashes win_path
154 let s2 = Drive.subst
s1 in
155 let unix_path = find s2 in
163 prerr_string
"Path.find2 Bad_file: ";
164 prerr_string
(String.copy win_path
);
166 prerr_string
(String.copy
s1);
168 prerr_string
(String.copy
s2);
178 let output oc dir_only win_path
=
180 if not
Wine.native
|| !Wine.native_convert_slashes
182 convert_slashes win_path
190 let s2 = Drive.subst
s1 in
198 let unix_path = find s3 in
206 prerr_string
"Path.output Bad_file: ";
207 prerr_string
( win_path
);
216 output_string oc win_path
220 output_string oc
(Filename.concat
s3 (Filename.basename s2))
222 output_string oc
unix_path
225 let prerr = output stderr
226 let print = output stdout
228 let abs_predicate s =
229 not
(Filename.is_relative
s) && Sys.file_exists
s
231 let check_and_modify_absolute_no_root s =
235 prerr_string
(String.escaped
s);
237 " is absolute and exists, but no wine drive mapping root is defined";
243 let check_and_modify_absolute_root root
s =
248 let r = String.create
(String.length
s + 2) in
256 ~
len:(String.length
s);
259 let r = String.create
(String.length
s + 1) in
267 ~
len:(String.length
s - 1);
272 let check_and_modify_absolute s =
277 match Drive.get_root
() with
279 check_and_modify_absolute_no_root s
281 check_and_modify_absolute_root root
s