diff options
author | ppedrot <ppedrot@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2012-05-08 10:52:31 +0000 |
---|---|---|
committer | ppedrot <ppedrot@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2012-05-08 10:52:31 +0000 |
commit | 3a95c46ee24a7877262b9c6572884cc262629f70 (patch) | |
tree | 22d5e15673d387ad85e2d2557ffa6848b4258af2 /ide/minilib.ml | |
parent | 0e1befcf9b15237220dfe2761484f361a963b952 (diff) |
Fixed access to environment variables in CoqIDE. Up to now, those
variables where set at compile time...
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@15287 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'ide/minilib.ml')
-rw-r--r-- | ide/minilib.ml | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/ide/minilib.ml b/ide/minilib.ml index 2400872a4..eba5499e9 100644 --- a/ide/minilib.ml +++ b/ide/minilib.ml @@ -71,33 +71,54 @@ let path_to_list p = (* On win32, the home directory is probably not in $HOME, but in some other environment variable *) -let home = +let home () = try Sys.getenv "HOME" with Not_found -> try (Sys.getenv "HOMEDRIVE")^(Sys.getenv "HOMEPATH") with Not_found -> try Sys.getenv "USERPROFILE" with Not_found -> Filename.current_dir_name -let xdg_config_home = +let xdg_config_home () = try Filename.concat (Sys.getenv "XDG_CONFIG_HOME") "coq" with Not_found -> - Filename.concat home "/.config/coq" - -let xdg_config_dirs = - xdg_config_home :: (try - List.map (fun dir -> Filename.concat dir "coq") (path_to_list (Sys.getenv "XDG_CONFIG_DIRS")) - with Not_found -> ["/etc/xdg/coq"])@(match Coq_config.configdir with |None -> [] |Some d -> [d]) + let home_dir = home () in + Filename.concat home_dir "/.config/coq" + +let xdg_config_dirs () = + let config_home = xdg_config_home () in + let config_list = + try path_to_list (Sys.getenv "XDG_CONFIG_DIRS") + with Not_found -> ["/etc/xdg"] + in + let remaining = + List.map (fun dir -> Filename.concat dir "coq") config_list + in + let def = match Coq_config.configdir with + | None -> [] + | Some d -> [d] + in + config_home :: remaining @ def -let xdg_data_home = +let xdg_data_home () = try Filename.concat (Sys.getenv "XDG_DATA_HOME") "coq" with Not_found -> - Filename.concat home "/.local/share/coq" - -let xdg_data_dirs = - xdg_data_home :: (try - List.map (fun dir -> Filename.concat dir "coq") (path_to_list (Sys.getenv "XDG_DATA_DIRS")) - with Not_found -> - ["/usr/local/share/coq";"/usr/share/coq"])@(match Coq_config.datadir with |None -> [] |Some d -> [d]) + let home_dir = home () in + Filename.concat home_dir "/.local/share/coq" + +let xdg_data_dirs () = + let data_home = xdg_data_home () in + let data_list = + try path_to_list (Sys.getenv "XDG_DATA_DIRS") + with Not_found -> ["/usr/local/share";"/usr/share"] + in + let remaining = + List.map (fun dir -> Filename.concat dir "coq") data_list + in + let def = match Coq_config.datadir with + | None -> [] + | Some d -> [d] + in + data_home :: remaining @ def let coqtop_path = ref "" |