mllib: move is_regular_file there

Move the is_regular_file function, implemented in virt-dib and virt-v2v,
to Common_utils.
This commit is contained in:
Pino Toscano
2015-10-15 16:24:25 +02:00
parent 42c60abfbd
commit 45bb7c8bcb
4 changed files with 7 additions and 7 deletions

View File

@@ -147,9 +147,6 @@ let copy_element element destdir blacklist =
let dirs, nondirs = List.partition is_directory entries in
let dirs = List.map (fun x -> (x, element.directory // x, destdir // x)) dirs in
let nondirs = List.map (fun x -> element.directory // x) nondirs in
let is_regular_file file =
try (Unix.stat file).Unix.st_kind = Unix.S_REG
with Unix.Unix_error _ -> false in
List.iter (
fun (e, path, destpath) ->
do_mkdir destpath;

View File

@@ -806,3 +806,7 @@ let read_first_line_from_file filename =
let line = input_line chan in
close_in chan;
line
let is_regular_file path = (* NB: follows symlinks. *)
try (Unix.stat path).Unix.st_kind = Unix.S_REG
with Unix.Unix_error _ -> false

View File

@@ -248,3 +248,6 @@ val last_part_of : string -> char -> string option
val read_first_line_from_file : string -> string
(** Read only the first line (i.e. until the first newline character)
of a file. *)
val is_regular_file : string -> bool
(** Checks whether the file is a regular file. *)

View File

@@ -159,10 +159,6 @@ let find_uefi_firmware guest_arch =
in
loop files
let is_regular_file path = (* NB: follows symlinks. *)
try (Unix.stat path).Unix.st_kind = Unix.S_REG
with Unix.Unix_error _ -> false
(* Given a path of a file relative to the root of the directory tree
* with virtio-win drivers, figure out if it's suitable for the
specific Windows flavor of the current guest.