70 lines
2.5 KiB
Plaintext
70 lines
2.5 KiB
Plaintext
|
$OpenBSD: patch-ubase_util_ml,v 1.1 2005/05/30 19:27:45 sturm Exp $
|
||
|
Post-release developer patch.
|
||
|
o Catch failure of localtime library call.
|
||
|
See http://lists.seas.upenn.edu/pipermail/unison-hackers/2005-May/000092.html
|
||
|
o Fix the order of looking for home directory.
|
||
|
See http://lists.seas.upenn.edu/pipermail/unison-hackers/2005-May/000088.html
|
||
|
--- ubase/util.ml.orig Mon Sep 6 15:15:47 2004
|
||
|
+++ ubase/util.ml Fri May 27 16:59:57 2005
|
||
|
@@ -244,14 +244,18 @@ let time () =
|
||
|
convertUnixErrorsToTransient "time" Unix.time
|
||
|
|
||
|
let time2string timef =
|
||
|
- let time = localtime timef in
|
||
|
- Printf.sprintf
|
||
|
- "%2d:%.2d on %2d %3s, %4d"
|
||
|
- time.Unix.tm_hour
|
||
|
- time.Unix.tm_min
|
||
|
- time.Unix.tm_mday
|
||
|
- (monthname time.Unix.tm_mon)
|
||
|
- (time.Unix.tm_year + 1900)
|
||
|
+ try
|
||
|
+ let time = localtime timef in
|
||
|
+ Printf.sprintf
|
||
|
+ "%2d:%.2d:%.2d on %2d %3s, %4d"
|
||
|
+ time.Unix.tm_hour
|
||
|
+ time.Unix.tm_min
|
||
|
+ time.Unix.tm_sec
|
||
|
+ time.Unix.tm_mday
|
||
|
+ (monthname time.Unix.tm_mon)
|
||
|
+ (time.Unix.tm_year + 1900)
|
||
|
+ with Transient _ ->
|
||
|
+ "(invalid date)"
|
||
|
|
||
|
let percentageOfTotal current total =
|
||
|
(int_of_float ((float current) *. 100.0 /. (float total)))
|
||
|
@@ -355,19 +359,20 @@ let padto n s = s ^ (String.make (max 0
|
||
|
(*****************************************************************************)
|
||
|
|
||
|
let fileInHomeDir n =
|
||
|
- match osType with
|
||
|
- `Win32 ->
|
||
|
- let dirString =
|
||
|
- try Unix.getenv "USERPROFILE" (* Windows NT/2K *)
|
||
|
- with Not_found ->
|
||
|
- try Unix.getenv "HOME" (* Windows 9x with Cygwin HOME set *)
|
||
|
- with Not_found ->
|
||
|
- try Unix.getenv "UNISON" (* Use UNISON dir if none of
|
||
|
- the above are set *)
|
||
|
- with Not_found -> "c:/" (* Default *) in
|
||
|
- Filename.concat dirString n
|
||
|
- | `Unix ->
|
||
|
- Filename.concat (safeGetenv "HOME") n
|
||
|
+ if osType = `Unix || isCygwin then
|
||
|
+ Filename.concat (safeGetenv "HOME") n
|
||
|
+ else if osType = `Win32 then
|
||
|
+ let dirString =
|
||
|
+ try Unix.getenv "USERPROFILE" (* Windows NT/2K *)
|
||
|
+ with Not_found ->
|
||
|
+ try Unix.getenv "HOME" (* Windows 9x with Cygwin HOME set *)
|
||
|
+ with Not_found ->
|
||
|
+ try Unix.getenv "UNISON" (* Use UNISON dir if none of
|
||
|
+ the above are set *)
|
||
|
+ with Not_found -> "c:/" (* Default *) in
|
||
|
+ Filename.concat dirString n
|
||
|
+ else
|
||
|
+ assert false (* osType can't be anything else *)
|
||
|
|
||
|
(*****************************************************************************)
|
||
|
(* "Upcall" for building pathnames in the .unison dir *)
|