module Extra:Extra definitions.sig
..end
typefilename =
string
typefoldername =
string
typecontent =
string
val current_umask : int
val touch : ?perm:Unix.file_perm -> filename -> unit
0o640
).module Copylib:sig
..end
val file_copy : ?perm:Unix.file_perm ->
filename -> filename -> unit
0o640
) concern of course the target.val file_append : ?perm:Unix.file_perm ->
filename -> filename -> unit
0o640
) concern of course the target.val put : ?perm:Unix.file_perm ->
filename -> content -> unit
0o640
).val rewrite : ?perm:Unix.file_perm ->
filename -> content -> unit
put
.val append : ?perm:Unix.file_perm ->
filename -> content -> unit
put
described above, but the content is appended instead of rewrited.
If the file doesn't exists, it is created with the given permissions (set by default to 0o640
).val cat : filename -> string
/etc/fstab
containing
the substring "hda1":
# "/etc/fstab" => ( cat || String.to_list || Str.grep ".*hda1.*" || hd )
module Templib:sig
..end
val temp_dir : ?perm:Unix.file_perm ->
?parent:string -> ?prefix:string -> ?suffix:string -> unit -> string
perm
are set to 0o755
"/tmp"
Example:
# temp_dir ();;
: string = "/tmp/819618234"
# temp_dir ~suffix:".txt" ();;
: string = "/tmp/625724514.txt"
val temp_file : ?perm:Unix.file_perm ->
?parent:string ->
?prefix:string ->
?suffix:string -> ?content:content -> unit -> string
temp_dir
. In addition, the parameter content
may be set in order
to put it in the created file. By default the content
is the empty string.
The function returns the name of the created directory.val file_kind_of_char : char -> Unix.file_kind option
Unix.file_kind = S_REG | S_DIR | S_CHR | S_BLK | S_LNK | S_FIFO | S_SOCK
The input character must belong to the set 'f';'d';'c';'b';'h';'p';'s'
,
following the convention of the standard unix test
command.
Otherwise, the result is None
.
val iter_dir : (string -> 'a) -> string -> unit
iter_dir f dirname
iterate the function f
on each entry of the directory dirname
.
-- From Xavier Leroy and Didier Remy's OS course, Chapter 2.module Findlib:sig
..end
val find : ?follow:bool ->
?maxdepth:int -> ?kind:char -> ?name:string -> string -> string list
Findlib.find
.
The default assignements are:
follow=false
maxdepth=1024
kind='_'
which implies no condition on kind name=""
which implies no condition on name. test
unix command (i.e.
'f';'d';'c';'b';'h';'p';'s'
); see the function UnixExtra.Extra.file_kind_of_char
for more details.
Warning: use this function with caution: the good version of this function will be a version returning a sequence (stream) instead of a list.
Examples:
# find "/etc/ssh/" ;;
: string list = ["/etc/ssh/"; "/etc/ssh/ssh_config"; "/etc/ssh/sshd_config";
"/etc/ssh/ssh_host_key"; "/etc/ssh/ssh_host_dsa_key.pub";
"/etc/ssh/ssh_host_rsa_key.pub"; "/etc/ssh/moduli";
"/etc/ssh/ssh_host_key.pub"; "/etc/ssh/ssh_host_dsa_key";
"/etc/ssh/ssh_host_rsa_key"]
# find ~kind:'d' "/etc/ssh/" ;;
: string list = ["/etc/ssh/"]
# find ~name:"moduli" "/etc/ssh/" ;;
: string list = ["/etc/ssh/moduli"]
module Passwdlib:sig
..end
val read_passwd : string -> string
typecommand =
string
val run : ?trace:bool ->
?input:content ->
command -> string * Unix.process_status
trace
(by default set to false
)
permits to obtain some informations about the running on stderr
.
Examples:
# run "ls /etc/*tab";;
: string * Unix.process_status =
("/etc/crontab\n/etc/fstab\n/etc/inittab\n/etc/mtab\n/etc/quotatab\n", Unix.WEXITED 0)
# run ~input:"hello" "cat";;
: string * Unix.process_status = ("hello", Unix.WEXITED 0)
# run ~input:"HELLO" "head -n 1 /etc/passwd /dev/stdin | cut -c-15";;
: string * Unix.process_status =
("==> /etc/passwd\nat:x:25:25:Batc\n\n==> /dev/stdin \nHELLO\n", Unix.WEXITED 0)
val shell : ?trace:bool ->
?input:content -> command -> string
run
, but ignoring the exit-code. This function is
simply a shortcut for the composition of run
with fst
. Examples:
# shell "date";;
: string = "ven avr 13 18:34:02 CEST 2007\n"
# String.Text.to_matrix (shell "wc -l /etc/*tab");;
: string list list =
[["8"; "/etc/crontab"]; ["20"; "/etc/fstab"]; ["98"; "/etc/inittab"];
["11"; "/etc/mtab"]; ["127"; "/etc/naccttab"]; ["9"; "/etc/quotatab"];
["273"; "total"]]