package file_path

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module type S = sig ... end
include S
include File_path_io.S with type 'a io := 'a
val executable_name : File_path.t Core.Lazy.t

The currently running executable.

OCaml semantics do not guarantee an absolute path here.

File I/O Wrappers

These functions abstract over either In_channel and Out_channel, or Async.Reader and Async.Writer.

val read_file : File_path.t -> string
val write_file : File_path.t -> contents:string -> unit
val load_sexp : File_path.t -> Core.Sexp.t
val load_sexps : File_path.t -> Core.Sexp.t list
val load_as_sexp : File_path.t -> of_sexp:(Core.Sexp.t -> 'a) -> 'a
val load_as_sexps : File_path.t -> of_sexp:(Core.Sexp.t -> 'a) -> 'a list
val save_sexp : File_path.t -> Core.Sexp.t -> unit
val save_sexps : File_path.t -> Core.Sexp.t list -> unit
val save_as_sexp : File_path.t -> 'a -> sexp_of:('a -> Core.Sexp.t) -> unit
val save_as_sexps : File_path.t -> 'a list -> sexp_of:('a -> Core.Sexp.t) -> unit

Filename Wrappers

These functions abstract over Filename_unix.

val realpath : File_path.t -> relative_to:File_path.Absolute.t -> File_path.Absolute.t
val realpath_absolute : File_path.Absolute.t -> File_path.Absolute.t
val realpath_relative_to_cwd : File_path.t -> File_path.Absolute.t

Sys Wrappers

These functions abstract over either Core.Sys or Async.Sys.

val exists : File_path.t -> [ `Yes | `No | `Unknown ]
val exists_exn : File_path.t -> bool
val is_directory : File_path.t -> [ `Yes | `No | `Unknown ]
val is_directory_exn : File_path.t -> bool
val is_file : File_path.t -> [ `Yes | `No | `Unknown ]
val is_file_exn : File_path.t -> bool
val ls_dir : File_path.t -> File_path.Part.t list

Unix Wrappers

These functions abstract over either Core_unix or Async.Unix.

val rmdir : File_path.t -> unit
val chdir : File_path.t -> unit
val getcwd : unit -> File_path.Absolute.t
val rename : src:File_path.t -> dst:File_path.t -> unit
val mkdir : ?parents:bool -> File_path.t -> unit

Current Directory Functions

These functions combine File_path and getcwd.

val make_absolute_under_cwd : File_path.t -> File_path.Absolute.t

Like File_path.make_absolute ~under:(getcwd ()). Avoids calling getcwd unless necessary.

val make_relative_to_cwd : File_path.t -> File_path.Relative.t option

Like File_path.make_relative ~if_under:(getcwd ()). Avoids calling getcwd unless necessary.

val make_relative_to_cwd_exn : File_path.t -> File_path.Relative.t

Like make_relative_to_cwd. Raises instead of returning None.

val make_relative_to_cwd_if_possible : File_path.t -> File_path.t

Like make_relative_to_cwd. Returns the original path instead of None.

OCaml

Innovation. Community. Security.