@@ -39,20 +39,33 @@ let serverHostName = localCanonicalHostName
3939let myCanonicalHostName () =
4040 if ! Trace. runningasserver then serverHostName else Prefs. read clientHostName
4141
42- let tempFilePrefix = " .unison."
43- let tempFileSuffixFixed = " .unison.tmp"
44- let tempFileSuffix = ref tempFileSuffixFixed
42+ let tempFilePrefixPref : string Prefs.t =
43+ Prefs. createString " tempfileprefix" " .unison"
44+ " !set the prefix for temporary files"
45+ (" When specified, all filenames of temporary files created by unison" ^
46+ " will begin with the set prefix." )
47+
48+ let tempFileSuffixPref : string Prefs.t =
49+ Prefs. createString " tempfilesuffix" " .unison.tmp"
50+ " !set the suffix for temporary files"
51+ (" When specified, all filenames of temporary files created by unison" ^
52+ " will end with the set suffix." )
53+
54+ let tempFilePrefix () = Prefs. read tempFilePrefixPref
55+ let tempFileSuffixFixed () = Prefs. read tempFileSuffixPref
56+
57+ let tempFileSuffix = ref (tempFileSuffixFixed () )
4558let includeInTempNames s =
4659 (* BCP: Added this in Jan 08. If (as I believe) it never fails, then this tricky
4760 stuff can be deleted. *)
4861 assert (s<> " " );
4962 tempFileSuffix :=
50- if s = " " then tempFileSuffixFixed
51- else " ." ^ s ^ tempFileSuffixFixed
63+ if s = " " then ( tempFileSuffixFixed () )
64+ else " ." ^ s ^ ( tempFileSuffixFixed () )
5265
5366let isTempFile file =
54- Util. endswith file tempFileSuffixFixed &&
55- Util. startswith file tempFilePrefix
67+ Util. endswith file ( tempFileSuffixFixed () ) &&
68+ Util. startswith file ( tempFilePrefix () )
5669
5770(* ****************************************************************************)
5871(* QUERYING THE FILESYSTEM *)
@@ -360,4 +373,5 @@ let genTempPath fresh fspath path prefix suffix =
360373 in f 0
361374
362375let tempPath ?(fresh =true ) fspath path =
376+ let tempFilePrefix = tempFilePrefix () in
363377 genTempPath fresh fspath path tempFilePrefix ! tempFileSuffix
0 commit comments