module type Fs_functions =sig
..end
include Uwt_base.Fs_types
type 'a
t
val openfile : ?perm:int ->
mode:uv_open_flag list -> string -> Uwt_base.file t
Equivalent to open(2).
perm
: defaults are 0o644val read : ?pos:int ->
?len:int -> Uwt_base.file -> buf:bytes -> int t
read ~pos ~len fd ~buf
reads ~len
bytes from descriptor fd
,
storing them in byte sequence buf
, starting at position ~pos
in
~buf
. Return the number of bytes actually read.
pos
: default is always zerolen
: default is always the still available length of the string /
bigarray / Bytes.tval read_ba : ?pos:int ->
?len:int -> Uwt_base.file -> buf:Uwt_base.buf -> int t
like Uwt_base.Fs_functions.read
, buf for bigarrays. Bigarrays are passed directly
to libuv (no copy to c heap or stack). It's faster, but you must manually
ensure, that the bigarray is not accessed from another thread.
val pread : ?pos:int ->
?len:int ->
Uwt_base.file -> fd_offset:int64 -> buf:bytes -> int t
Uwt_base.Fs_functions.pread
is equivalent to Uwt_base.Fs_functions.read
, except that it reads from a given
position ~fd_offset
in the file without changing the file offset.
val pread_ba : ?pos:int ->
?len:int ->
Uwt_base.file ->
fd_offset:int64 -> buf:Uwt_base.buf -> int t
val write : ?pos:int ->
?len:int -> Uwt_base.file -> buf:bytes -> int t
write fd ~pos ~len fd ~buf
writes ~len
bytes to descriptor fd
,
taking them from byte sequence buf
, starting at position ~pos
in ~buf
. Return the number of bytes actually written.
val write_string : ?pos:int ->
?len:int -> Uwt_base.file -> buf:string -> int t
val write_ba : ?pos:int ->
?len:int -> Uwt_base.file -> buf:Uwt_base.buf -> int t
val pwrite : ?pos:int ->
?len:int ->
Uwt_base.file -> fd_offset:int64 -> buf:bytes -> int t
Uwt_base.Fs_functions.pwrite
is equivalent to Uwt_base.Fs_functions.write
, except that it writes into
a given position ~fd_offset
and does not change the file offset
val pwrite_string : ?pos:int ->
?len:int ->
Uwt_base.file -> fd_offset:int64 -> buf:string -> int t
val pwrite_ba : ?pos:int ->
?len:int ->
Uwt_base.file ->
fd_offset:int64 -> buf:Uwt_base.buf -> int t
val writev : Uwt_base.file -> Uwt_base.Iovec_write.t list -> int t
write multiple buffers at once. If the number of buffers is greater than IOV_MAX, newer libuv versions already contains code to circumvent this issue
val pwritev : Uwt_base.file ->
Uwt_base.Iovec_write.t list -> int64 -> int t
Uwt_base.Fs_functions.pwritev
is equivalent to Uwt_base.Fs_functions.pwrite
, except that it writes into
a given position and does not change the file offset
val close : Uwt_base.file -> unit t
Close a file descriptor.
val unlink : string -> unit t
delete a name and possibly the file it refers to
val mkdir : ?perm:int -> string -> unit t
Create a directory.
perm
: defaults are 0o777val rmdir : string -> unit t
Delete an empty directory
val fsync : Uwt_base.file -> unit t
synchronize a file's in-core state with storage device.
val fdatasync : Uwt_base.file -> unit t
Uwt_base.Fs_functions.fdatasync
is similar to Uwt_base.Fs_functions.fsync
, but does not flush modified metadata
unless that metadata is needed in order to allow a subsequent data
retrieval to be correctly handled.
val ftruncate : Uwt_base.file -> len:int64 -> unit t
truncate a file to a specified length
val stat : string -> stats t
Return the information for the named file.
val lstat : string -> stats t
Uwt_base.Fs_functions.lstat
is identical to Uwt_base.Fs_functions.stat
, except that if pathname is a symbolic
link. In this case it returns information about the link itself.
val fstat : Uwt_base.file -> stats t
Uwt_base.Fs_functions.fstat
is identical to Uwt_base.Fs_functions.stat
, except that the file about which
information is to be retrieved is specified by the file descriptor
val rename : src:string -> dst:string -> unit t
change the name or location of a file
val link : target:string -> link_name:string -> unit t
Uwt_base.Fs_functions.link
creates a new link (also known as a hard link) to an existing
file
val symlink : ?mode:symlink_mode ->
src:string -> dst:string -> unit -> unit t
Uwt_base.Fs_functions.symlink
creates a symbolic link named ~dst
which contains
the string ~src
mode
: default S_Default
val mkdtemp : string -> string t
The Uwt_base.Fs_functions.mkdtemp
function generates a uniquely named temporary directory
from template. The last six characters of template must be XXXXXX and
these are replaced with a string that makes the directory name unique
val sendfile : ?pos:int64 ->
?len:nativeint ->
dst:Uwt_base.file ->
src:Uwt_base.file -> unit -> nativeint t
A limited equivalent to sendfile(2)
. It copies data between one file
descriptor and another
pos
: default 0len
: Nativeint.max_int
val utime : string -> access:float -> modif:float -> unit t
Uwt_base.Fs_functions.utime
changes the access and modification times of a file. If
both times are 0.0
, the access and last modification times are
both set to the current time.
val futime : Uwt_base.file -> access:float -> modif:float -> unit t
Uwt_base.Fs_functions.futime
is identical to Uwt_base.Fs_functions.utime
, except that the file about which
information is to be retrieved is specified by the file descriptor
val readlink : string -> string t
Uwt_base.Fs_functions.readlink
reads the value of a symbolic link
val access : string -> access_permission list -> unit t
Check user's permissions for a file
val chmod : string -> perm:int -> unit t
Change the permissions of the named file.
val fchmod : Uwt_base.file -> perm:int -> unit t
Change the permissions of an opened file.
val chown : string -> uid:int -> gid:int -> unit t
Change the owner ~uid
and owner ~gid
of the named file.
val fchown : Uwt_base.file -> uid:int -> gid:int -> unit t
Change the owner ~uid
and owner ~gid
of the opened file.
val lchown : string -> uid:int -> gid:int -> unit t
like chown, but do not dereference symbolic links
val scandir : string -> (file_kind * string) array t
On Linux, getting the type of an entry is only supported by some filesystems (btrfs, ext2, ext3 and ext4 at the time of this writing), check the getdents(2) man page.
val realpath : string -> string t
Equivalent to realpath(3) on Unix. Windows uses GetFinalPathNameByHandle.
Warning This function has certain platform specific caveats that were discovered when used in Node.
macOS and other BSDs: this function will fail with UV_ELOOP if more than 32 symlinks are found while resolving the given path. This limit is hardcoded and cannot be sidestepped.
Windows: while this function works in the common case, there are a number of corner cases where it doesn't:
While this function can still be used, it's not recommended if scenarios such as the above need to be supported.
val copyfile : ?excl:bool ->
?clone:clone_mode ->
src:string -> dst:string -> unit -> unit t
Copies a file from ~src
to ~dst
.
If ?excl
is true, copyfile will fail with EEXIST
if the
destination path already exists. The default behavior is to
overwrite the destination if it exists.
If ?clone
is Try_clone
, copyfile will attempt to create a
copy-on-write reflink. If the underlying platform (or your installed
libuv version) does not support copy-on-write, then a fallback copy
mechanism is used.
If ?clone
is Force_clone
, copyfile will attempt to create a
copy-on-write reflink. If the underlying platform does not support
copy-on-write, then an error is returned.
The default behaviour is a normal copy (No_clone
).
Warning: If the destination path is created, but an error occurs while copying the data, then the destination path is removed. There is a brief window of time between closing and removing the file where another process could access the file.