1 let drive_tbl = Array.create
(Char.code 'z'
- Char.code 'a'
+ 1) None
5 if i
= Array.length
drive_tbl
9 match drive_tbl.(i
) with
11 Some
(Char.chr
(Char.code 'a'
+ i
))
21 let slen = String.length s
in
28 let c = Char.lowercase s
.[0] in
29 (* prerr_string "Drive "; *)
31 (* prerr_newline (); *)
32 let i = Char.code
c - Char.code 'a'
in
33 if i < Array.length
drive_tbl
35 match drive_tbl.(i) with
39 let dlen = String.length d
in
40 let r = String.create
(slen - 2 + dlen) in
56 prerr_string
"Drive.subst bogus drive ";
57 prerr_endline
(String.escaped s
);
62 prerr_string
"Drive.subst no slash ";
63 prerr_endline
(String.escaped s
);
71 let process_exn s
= function
72 | Unix.Unix_error
(code
, fn_name
, fn_arg
) ->
77 if String.length fn_arg
> 0
81 prerr_endline
(Unix.error_message code
)
85 prerr_endline
(Printexc.to_string exn
)
87 let process_dosdevices dir_path dir
=
88 let get_path_drive win_path
=
89 if String.length win_path
= 2
93 let c = Char.lowercase win_path
.[0] in
94 if (c >= 'a'
&& c <= 'z'
)
105 let put_drive drive_letter unix_path
=
106 let i = Char.code drive_letter
- Char.code 'a'
in
107 let l = String.length unix_path
in
109 if unix_path
.[l - 1] = '
/'
111 String.sub unix_path
0 (pred
l)
115 drive_tbl.(i) <- Some
drive_path
121 let s = Unix.readdir dir
in
125 (* prerr_endline "Drive(readdir): empty directory"; *)
133 match get_path_drive s with
137 Some
(Unix.readlink
(Filename.concat dir_path
s))
141 "Drive.process_dosdevices(loop:readlink)"
145 Utils.some_action
(put_drive c) () opt_target
156 process_exn "Drive.process_dosdevices(loop:?)" exn
161 let _A = Char.code 'A'
in
162 for i = 0 to pred
(Array.length
drive_tbl) do
164 s.[0] <- Char.chr
(i + _A);
165 drive_tbl.(i) <- Some
s
168 let dir_path = Filename.concat
Wine.root_path
"dosdevices" in
171 Some
(Unix.opendir
dir_path)
174 process_exn "Drive.init" exn
;
179 prerr_endline
"Can not establish drive mapping";
181 process_dosdevices dir_path dir
;
187 process_exn "Drive.init" exn
;