23 |
open Options |
open Options |
24 |
open Gettext |
open Gettext |
25 |
|
|
26 |
let filename = Filename.concat CommonOptions.home_dir "mlnet_strings" |
let bin_dir = Filename.dirname Sys.argv.(0) |
27 |
|
|
28 |
|
let hidden_dir_prefix = |
29 |
|
if Autoconf.system = "windows" then "" else "." |
30 |
|
|
31 |
|
let config_dir_basename = hidden_dir_prefix ^ "mldonkey" |
32 |
|
|
33 |
|
let home_dir = |
34 |
|
match Autoconf.system with |
35 |
|
| "windows" -> if (Filename.basename bin_dir) = "bin" then Filename.dirname bin_dir else "." |
36 |
|
| _ -> Filename.concat (try Sys.getenv "HOME" with _ -> ".") config_dir_basename |
37 |
|
|
38 |
|
let file_basedir_pre = |
39 |
|
try |
40 |
|
let s = Sys.getenv "MLDONKEY_DIR" in |
41 |
|
if s = "" then home_dir else Filename2.normalize s |
42 |
|
with _ -> home_dir |
43 |
|
|
44 |
|
let file_basedir = |
45 |
|
(* Creating dirs does work differently on Windows than Unix. |
46 |
|
Dirs like c:\b are split down by unix2.safe_mkdir to "c". |
47 |
|
This function splits the directory name into the drive name |
48 |
|
and chdir to it before creating directories. |
49 |
|
Non-absolute paths in $MLDONKEY_DIR do not work as well *) |
50 |
|
if Sys.file_exists (Filename.concat (Sys.getcwd ()) "mlgui.ini") then |
51 |
|
"." |
52 |
|
else |
53 |
|
if Autoconf.system = "windows" && file_basedir_pre <> home_dir then |
54 |
|
match String2.split file_basedir_pre ':' with |
55 |
|
| drive :: directory :: _ -> |
56 |
|
Unix.chdir (drive ^ ":\\"); |
57 |
|
directory |
58 |
|
| _ -> lprintf "Please provide an absolute path in MLDONKEY_DIR like d:\\mldonkey, exiting...\n"; exit 2 |
59 |
|
else file_basedir_pre |
60 |
|
|
61 |
|
let _ = |
62 |
|
if not !CommonGlobals.core_included |
63 |
|
then begin |
64 |
|
(try |
65 |
|
Unix2.safe_mkdir file_basedir |
66 |
|
with e -> |
67 |
|
lprintf_nl "Exception (%s) trying to create dir %s" |
68 |
|
(Printexc2.to_string e) file_basedir; |
69 |
|
exit 2); |
70 |
|
Unix2.can_write_to_directory file_basedir; |
71 |
|
Unix.chdir file_basedir; |
72 |
|
lprintf_nl "Starting MLGui %s ... " Autoconf.current_version; |
73 |
|
lprintf_nl "MLGui is working in %s" (Sys.getcwd ()) |
74 |
|
end |
75 |
|
|
76 |
|
|
77 |
|
let dirname_concat dir = |
78 |
|
match Autoconf.system with |
79 |
|
"windows" -> Filename.concat file_basedir dir |
80 |
|
| _ -> file_basedir |
81 |
|
|
82 |
|
let lang_dir = dirname_concat "lang" |
83 |
|
let gui_config_dir = dirname_concat "interface" |
84 |
|
let log_dir = dirname_concat "logs" |
85 |
|
|
86 |
|
let _ = |
87 |
|
if not !CommonGlobals.core_included |
88 |
|
then begin |
89 |
|
let filename = |
90 |
|
try |
91 |
|
Sys.getenv "MLGUI_STRINGS" |
92 |
|
with _ -> |
93 |
|
Filename.concat lang_dir "mlgui_strings" |
94 |
|
in |
95 |
|
Unix2.safe_mkdir (Filename.dirname filename); |
96 |
|
Unix2.can_write_to_directory (Filename.dirname filename); |
97 |
|
set_strings_file filename |
98 |
|
end |
99 |
|
|
100 |
let _s x = (* lprintf "searching string %s\n" x; *) GuiUtf8.simple_utf8_of (_s "GuiMessages" x) |
let _s x = (* lprintf "searching string %s\n" x; *) GuiUtf8.simple_utf8_of (_s "GuiMessages" x) |
101 |
|
|
342 |
|
|
343 |
(* Graph *) |
(* Graph *) |
344 |
|
|
345 |
|
let gT_lb_time_range = ref "" |
346 |
|
let gT_lb_quarter = ref "" |
347 |
|
let gT_lb_hour = ref "" |
348 |
|
let gT_lb_halfday = ref "" |
349 |
|
let gT_lb_day = ref "" |
350 |
|
let gT_lb_week = ref "" |
351 |
|
let gT_lb_month = ref "" |
352 |
|
let gT_lb_year = ref "" |
353 |
|
let gT_lb_global_downloads = ref "" |
354 |
|
let gT_lb_global_uploads = ref "" |
355 |
|
let gT_lb_file_down_up = ref "" |
356 |
|
|
357 |
(* file Window *) |
(* file Window *) |
358 |
|
|
359 |
let fW_wt_show_file_details = ref "" |
let fW_wt_show_file_details = ref "" |
799 |
|
|
800 |
(* Graph *) |
(* Graph *) |
801 |
|
|
802 |
|
gT_lb_time_range := _s_ "Time range"; |
803 |
|
gT_lb_quarter := _s "Quarter"; |
804 |
|
gT_lb_hour := _s "Hour"; |
805 |
|
gT_lb_halfday := _s "Half day"; |
806 |
|
gT_lb_day := _s "Day"; |
807 |
|
gT_lb_week := _s "Week"; |
808 |
|
gT_lb_month := _s "Month"; |
809 |
|
gT_lb_year := _s "Year"; |
810 |
|
gT_lb_global_downloads := _s "Global Downloads"; |
811 |
|
gT_lb_global_uploads := _s "Global Uploads"; |
812 |
|
gT_lb_file_down_up := _s "Files Uploads and Downloads"; |
813 |
|
|
814 |
(* file Window *) |
(* file Window *) |
815 |
|
|
816 |
fW_wt_show_file_details := _s "File details"; |
fW_wt_show_file_details := _s "File details"; |
1065 |
|
|
1066 |
(* Messages and string constants. *) |
(* Messages and string constants. *) |
1067 |
|
|
1068 |
let chat_config_file = |
let _ = Unix2.safe_mkdir gui_config_dir |
1069 |
Filename.concat CommonOptions.home_dir "chat.ini" |
|
1070 |
|
let chat_config_file = Filename.concat gui_config_dir "chat.ini" |
1071 |
|
|
1072 |
(* {2 Command line messages} *) |
(* {2 Command line messages} *) |
1073 |
|
|