summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/uicommon.ml13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/uicommon.ml b/src/uicommon.ml
index 5204605..c6ebd53 100644
--- a/src/uicommon.ml
+++ b/src/uicommon.ml
@@ -494,6 +494,12 @@ let promptForRoots getFirstRoot getSecondRoot =
(* ---- *)
+let makeTempDir pattern =
+ let ic = Unix.open_process_in (Printf.sprintf "(mktemp --tmpdir -d %s || mktemp -d -t %s) 2>/dev/null" pattern pattern) in
+ let path = input_line ic in
+ ignore (Unix.close_process_in ic);
+ path
+
(* The first time we load preferences, we also read the command line
arguments; if we re-load prefs (because the user selected a new profile)
we ignore the command line *)
@@ -545,9 +551,12 @@ let initPrefs ~profileName ~displayWaitMessage ~getFirstRoot ~getSecondRoot
(* Install dummy roots and backup directory if we are running self-tests *)
if Prefs.read runtests then begin
if Globals.rawRoots() = [] then
- Prefs.loadStrings ["root = test-a.tmp"; "root = test-b.tmp"];
+ Prefs.loadStrings [
+ String.concat " = " ["root"; makeTempDir "test-a"];
+ String.concat " = " ["root"; makeTempDir "test-b"]
+ ];
if (Prefs.read Stasher.backupdir) = "" then
- Prefs.loadStrings ["backupdir = test-backup.tmp"];
+ Prefs.loadStrings [ String.concat " = " ["backupdir"; makeTempDir "test-backup"] ]
end;
(* Print the preference settings *)