[Libguestfs] [PATCH v4 8/9] mllib: add do_mv helper function to Common_utils

Cédric Bosdonnat
Tue, 07 Mar 2017 14:27:04 -0000

---
 mllib/common_utils.ml  | 6 ++++++
 mllib/common_utils.mli | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 945728b5e..7932707c9 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -1172,3 +1172,9 @@ let do_cp src destdir    let cmd = [ "cp";
"-t"; destdir; "-a"; src ] in
   if run_command cmd <> 0 then
     error (f_"copy of %s to %s failed") src destdir
+
+let do_mv src dest +  let cmd = [ "mv"; src; dest ] in
+  let r = run_command cmd in
+  if r <> 0 then
+    error (f_"moving file '%s' to '%s' failed") src
dest
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
index 5c376fcb3..33d576b5e 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -494,4 +494,7 @@ val inspect_decrypt : Guestfs.guestfs -> unit
     for Fedora whole-disk encryption. *)

 val do_cp : string -> string -> unit
-(** Run the cp command, and exit with an error if it failed *)
+(** Run the cp command and exit with an error if it failed *)
+
+val do_mv : string -> string -> unit
+(** Run the mv command and exit with an error if it failed *)
--
2.11.0