42 |
|
|
43 |
|
|
44 |
(************* ADD/REMOVE FUNCTIONS ************) |
(************* ADD/REMOVE FUNCTIONS ************) |
45 |
|
let check_forbidden_chars (uc : Charset.uchar) = |
46 |
|
match uc with |
47 |
|
| 47 (* '/' *) |
48 |
|
| 92 (* '\\' *) -> 95 (* '_' *) |
49 |
|
(* Windows can't do these *) |
50 |
|
| 58 (* ':' *) |
51 |
|
| 42 (* '*' *) |
52 |
|
| 63 (* '?' *) |
53 |
|
| 34 (* '"' *) |
54 |
|
| 60 (* '<' *) |
55 |
|
| 62 (* '>' *) |
56 |
|
| 124 (* '|' *) |
57 |
|
| 37 (* '%' *) when Autoconf.system = "windows" -> 95 (* '_' *) |
58 |
|
| _ -> uc |
59 |
|
|
60 |
let canonize_basename name = |
let canonize_basename name = |
61 |
let buf = Buffer.create 100 in |
let buf = Buffer.create 100 in |
62 |
for i = 0 to String.length name - 1 do |
let uname = Charset.to_utf8 name in |
63 |
|
for i = 0 to Charset.utf8_length uname - 1 do |
64 |
(* replace chars on users request *) |
(* replace chars on users request *) |
65 |
let c = name.[i] in |
let uc = Charset.utf8_get uname i in |
|
let nc = int_of_char c in |
|
66 |
try |
try |
67 |
Buffer.add_string buf (List.assoc nc !!filename_conversions) |
let us = List.assoc uc !!utf8_filename_conversions in |
68 |
|
for j = 0 to Charset.utf8_length us - 1 do |
69 |
|
let uc' = Charset.utf8_get us j in |
70 |
|
let uc'' = check_forbidden_chars uc' in |
71 |
|
Charset.add_uchar buf uc'' |
72 |
|
done |
73 |
with _ -> |
with _ -> |
74 |
Buffer.add_char buf |
begin |
75 |
(match c with |
let uc' = check_forbidden_chars uc in |
76 |
| '/' | '\\' -> '_' |
Charset.add_uchar buf uc' |
77 |
(* Windows can't do these *) |
end |
|
| ':' | '*' | '?' | '"' | '<' | '>' | '|' | '%' when Autoconf.system = "windows" -> '_' |
|
|
| _ -> c |
|
|
) |
|
78 |
done; |
done; |
79 |
Charset.to_locale (Buffer.contents buf) |
Charset.to_locale (Buffer.contents buf) |
80 |
|
|
81 |
let file_commited_name incoming_dir file = |
let file_commited_name incoming_dir file = |
82 |
let network = file_network file in |
let network = file_network file in |
83 |
let best_name = file_best_name file in |
let best_name = file_best_name file in |