[Libguestfs] [PATCH v6 08/10] mllib: add do_mv helper function to Common_utils

Cédric Bosdonnat cbosdonnat at suse.com
Wed Apr 12 12:33:10 UTC 2017


---
 mllib/common_utils.ml  | 6 ++++++
 mllib/common_utils.mli | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index ceac57711..5cc865659 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -1191,3 +1191,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 937ef818b..64a0e8b9a 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -499,3 +499,6 @@ val inspect_decrypt : Guestfs.guestfs -> unit
 
 val do_cp : string -> string -> unit
 (** 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.12.0




More information about the Libguestfs mailing list