diff options
author | Benjamin Pierce <bcpierce00@users.noreply.github.com> | 2018-02-09 12:48:25 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-09 12:48:25 -0500 |
commit | 5faea1e4c75e1a9c2c2d51e720de216ef28c0e32 (patch) | |
tree | 45bde6ccb5387a3733e5d60c7d42e54bc82a8eda /src | |
parent | b2c6a0df6ff0d8fdac499a6b6e97bc4b7ba2baa0 (diff) | |
parent | 3f36a21bfea40aa08f8d25f96dd1d10f8be05284 (diff) | |
download | unison-5faea1e4c75e1a9c2c2d51e720de216ef28c0e32.zip unison-5faea1e4c75e1a9c2c2d51e720de216ef28c0e32.tar.gz unison-5faea1e4c75e1a9c2c2d51e720de216ef28c0e32.tar.bz2 |
Merge pull request #149 from g-raud/logfile-relative-to-home
'logfile': when relative path then root to home
Diffstat (limited to 'src')
-rw-r--r-- | src/ubase/trace.ml | 5 | ||||
-rw-r--r-- | src/ubase/util.ml | 5 | ||||
-rw-r--r-- | src/ubase/util.mli | 1 |
3 files changed, 9 insertions, 2 deletions
diff --git a/src/ubase/trace.ml b/src/ubase/trace.ml index 08caddf..d47054a 100644 --- a/src/ubase/trace.ml +++ b/src/ubase/trace.ml @@ -117,7 +117,7 @@ let logfile = "!logfile name" "By default, logging messages will be appended to the file \\verb|unison.log| in your HOME directory. Set this preference if - you prefer another file." + you prefer another file. It can be a path relative to your HOME directory." let logch = ref None @@ -125,7 +125,8 @@ let rec getLogch() = Util.convertUnixErrorsToFatal "getLogch" (fun() -> match !logch with None -> - let file = Prefs.read logfile in + let prefstr = System.fspathToString (Prefs.read logfile) in + let file = Util.fileMaybeRelToHomeDir prefstr in let ch = System.open_out_gen [Open_wronly; Open_creat; Open_append] 0o600 file in logch := Some (ch, file); diff --git a/src/ubase/util.ml b/src/ubase/util.ml index 8af4714..6b9c760 100644 --- a/src/ubase/util.ml +++ b/src/ubase/util.ml @@ -460,6 +460,11 @@ let homeDir () = let fileInHomeDir n = System.fspathConcat (homeDir ()) n +let fileMaybeRelToHomeDir n = + if Filename.is_relative n + then fileInHomeDir n + else System.fspathFromString n + (*****************************************************************************) (* "Upcall" for building pathnames in the .unison dir *) (*****************************************************************************) diff --git a/src/ubase/util.mli b/src/ubase/util.mli index b213560..bd8d804 100644 --- a/src/ubase/util.mli +++ b/src/ubase/util.mli @@ -79,6 +79,7 @@ val percentageOfTotal : val monthname : int -> string val percent2string : float -> string val fileInHomeDir : string -> System.fspath +val fileMaybeRelToHomeDir : string -> System.fspath val homeDirStr : string (* Just like the versions in the Unix module, but raising Transient |