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

Cédric Bosdonnat cbosdonnat at suse.com
Thu Mar 23 09:02:46 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 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..a98daad03 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -495,3 +495,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