package spotlib

  1. Overview
  2. Docs
include module type of struct include Stdlib.Filename end
val current_dir_name : string
val parent_dir_name : string
val dir_sep : string
val concat : string -> string -> string
val is_relative : string -> bool
val is_implicit : string -> bool
val check_suffix : string -> string -> bool
val chop_suffix : string -> string -> string
val chop_suffix_opt : suffix:string -> string -> string option
val extension : string -> string
val remove_extension : string -> string
val chop_extension : string -> string
val basename : string -> string
val dirname : string -> string
val null : string
val temp_file : ?temp_dir:string -> string -> string -> string
val open_temp_file : ?mode:Stdlib.open_flag list -> ?perms:int -> ?temp_dir:string -> string -> string -> string * Stdlib.out_channel
val get_temp_dir_name : unit -> string
val set_temp_dir_name : string -> unit
val temp_dir_name : string
  • deprecated Use Filename.get_temp_dir_name instead
val quote : string -> string
val quote_command : string -> ?stdin:string -> ?stdout:string -> ?stderr:string -> string list -> string
include module type of struct include Xfilename end
val split_extension : string -> string * string

split_extension path split the body and extension of path. split_extension "hello.world.txt" = "hello.world", ".txt" split_extension "hello_world" = "hello_world", ""

val change_extension : string -> ext:string -> string

change_extension f ~ext changes the extension part of f. If f has no extension then change_extension f ~ext just attach ext to f.

change_extension "hello_world.txt" ~ext:".obj" = "hello_world.obj" change_extension "hello.world.txt" ~ext:".obj" = "hello.world.obj" change_extension "hello_world" ~ext:".obj" = "hello_world.obj" change_extension "hello_world" ~ext:"obj" = "hello_worldobj"

Note that change_extension does not check ext begins with '.' or not.

val split_dir : string -> string list

split_dir path splits path recursively using dirname and returns the list of directory and basename components of path.

split_dir "/a/b/c/d" = ["/"; "a"; "b"; "c"; "d"] split_dir "/a/b/c/d/" = ["/"; "a"; "b"; "c"; "d"] split_dir "a/b/c/d" = ["."; "a"; "b"; "c"; "d"]

split_dir "/a/b/./c/d" = ["/"; "a"; "b"; "."; "c"; "d"] split_dir "/a/b/../c/d" = ["/"; "a"; "b"; ".."; "c"; "d"] split_dir "../a/b/c/d" = ["."; ".."; "a"; "b"; "c"; "d"]

In Windows, split_dir "c:/a/b/c/d" = ["c:/"; "a"; "b"; "c"; "d"] split_dir "\\a\\b\\c\\d" = ["\\"; "a"; "b"; "c"; "d"]

val is_root : string -> bool
val concats : string list -> string
module Stdlib = Xfilename.Stdlib
OCaml

Innovation. Community. Security.