|
@@ -44,13 +44,10 @@ type lock_status =
|
|
|
| Free
|
|
|
| Err
|
|
|
;;
|
|
|
-(* Name of the lock file *)
|
|
|
-(* TODO Put it in Const *)
|
|
|
-let lock_name = "/tmp/.ocl.lock";;
|
|
|
|
|
|
(* Create lock file *)
|
|
|
let lock () =
|
|
|
- try Out_channel.write_all lock_name ~data:"OcLaunch is running and did not finish."
|
|
|
+ try Out_channel.write_all Const.lock_file ~data:"OcLaunch is running and did not finish."
|
|
|
with Sys_error msg ->
|
|
|
Messages.debug "Couldn't write in lock file.";
|
|
|
Messages.debug "Due to";
|
|
@@ -59,7 +56,7 @@ let lock () =
|
|
|
|
|
|
(* To know if we are locked, return None if there is no locker, *)
|
|
|
let status () =
|
|
|
- match Sys.file_exists lock_name with
|
|
|
+ match Sys.file_exists Const.lock_file with
|
|
|
`Yes -> Locked
|
|
|
| `No -> Free
|
|
|
| `Unknown -> Err
|
|
@@ -67,7 +64,11 @@ let status () =
|
|
|
|
|
|
(* Remove the lock file *)
|
|
|
let remove () =
|
|
|
- Sys.remove lock_name
|
|
|
+ let open Sys in
|
|
|
+ file_exists Const.lock_file
|
|
|
+ |> function
|
|
|
+ | `Yes -> remove Const.lock_file
|
|
|
+ | _ -> Messages.debug "No lock file"
|
|
|
;;
|
|
|
|
|
|
(* Pause the program until lock file is removed, until argument is the second *)
|