X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=utils.mli;h=ca792ca0722dbf51a69d1841086d837c65d41fde;hb=87a075aaada42182cd7047d110f83eaa8273b78d;hp=f2a00db131b14ade88a43a5eee470f49ae5a3afa;hpb=bbfe03c47f1d7f03c3e6c0cab9e4f500f588c80a;p=guestfs-browser.git diff --git a/utils.mli b/utils.mli index f2a00db..ca792ca 100644 --- a/utils.mli +++ b/utils.mli @@ -18,18 +18,131 @@ (** General-purpose utility code used everywhere. *) +val (+^) : int64 -> int64 -> int64 +val (-^) : int64 -> int64 -> int64 +val ( *^ ) : int64 -> int64 -> int64 +val (/^) : int64 -> int64 -> int64 + (** Int64 arithmetic operators. *) + type ('a, 'b) either = Left of 'a | Right of 'b (** A value which is either an ['a] or a ['b], just like Haskell's "Either" type. *) -val verbose : bool ref +val (//) : string -> string -> string + (** Concatenate two paths. *) + +val verbose : unit -> bool +val set_verbose_flag : unit -> unit (** If this contains [true] then {!debug} will send debugging - messages to stderr, else debugging messages are dropped. *) + messages to stderr, else debugging messages are dropped. -val debug : ('a, out_channel, unit) format -> 'a + This is set through the --verbose command line option. *) + +val debug : ('a, unit, string, unit) format4 -> 'a (** A printf-like function for writing debugging messages. *) -val failwith : ('a, out_channel, unit) format -> 'a +val failwith : ('a, unit, string, 'b) format4 -> 'a (** Replacement for standard OCaml [failwith] function. This can take a printf-like argument list, and also logs errors on stderr when verbose is enabled. *) + +val trace : unit -> bool +val set_trace_flag : unit -> unit + (** If this contains [true] then calls to libguestfs are traced. + + This is set through the [-x] command line option. *) + +val connect_uri : unit -> string option +val set_connect_uri : string option -> unit + (** The libvirt connection URI. + + This is set through the [--connect] command line option. *) + +val pretty_string_of_exn : exn -> string * string + (** Pretty string from exception. + + Returns a title and a detailed message, for use in message dialogs. + + To get raw exception string, use {!Printexc.to_string} from the + standard library. *) + +val utf8_rarrow : string (** UTF-8 RIGHTWARDS ARROW *) + +val human_size : int64 -> string + (** Convert a number of bytes into a human readable string. *) + +val human_size_1k : int64 -> string + (** Same as {!human_size} but the argument is 1KB blocks (used for + disk usage). *) + +val unique : unit -> int + (** Return a new integer each time called. *) + +val mklabel : string -> GObj.widget + (** Convenience function to make a label containing some text. It is + returned as a generic widget. *) + +val markup_escape : string -> string + (** Like g_markup_escape but with extra protection for strings + containing \0 characters. *) + +val libguestfs_version_string : unit -> string + (** Return the version of libguestfs as a string. *) + +val libvirt_version_string : unit -> string + (** Return the version of libvirt as a string. *) + +val is_socket : int64 -> bool +val is_symlink : int64 -> bool +val is_regular_file : int64 -> bool +val is_block : int64 -> bool +val is_directory : int64 -> bool +val is_char : int64 -> bool +val is_fifo : int64 -> bool + (** File type tests. *) + +val is_suid : int64 -> bool +val is_sgid : int64 -> bool +val is_svtx : int64 -> bool + (** File setuid, setgid, sticky bit tests. *) + +val is_ru : int64 -> bool +val is_wu : int64 -> bool +val is_xu : int64 -> bool +val is_rg : int64 -> bool +val is_wg : int64 -> bool +val is_xg : int64 -> bool +val is_ro : int64 -> bool +val is_wo : int64 -> bool +val is_xo : int64 -> bool + (** rwx/ugo bits. *) + +val tmpdir : unit -> string + (** [tmpdir ()] returns a newly created temporary directory. The + tmp directory is automatically removed when the program exits. + Note that a fresh temporary directory is returned each time you + call this function. *) + +val windows_string_to_utf8 : string -> string + (** Convert a UTF16LE string to UTF8. This also removes the final + \0 word if there is one. + + This may fail in multiple ways, raising a Camomile exception + which you probably need to catch. *) + +val printable_hivex_value : ?split_long_lines:bool -> Hivex.hive_type -> string -> string + (** [printable_hivex_value t v] converts raw registry value + [v] of type [t] to a printable string. *) + +val local_file_exists : string -> bool + (** Returns true if the (local) file exists. *) + +val basename : string -> string + (** Get the basename of a file, using path conventions which are valid + for libguestfs. So {!Filename.basename} won't necessarily work + because it will use host path conventions. *) + +val extension : string -> string + (** Get the extension of a file using libguestfs path conventions, + including the leading point (eg. [.txt]). Might return an empty + string if there is no extension. *)