Skip to content

Commit

Permalink
Make symlink signatures more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
talex5 committed Apr 4, 2024
1 parent 9096a87 commit 8b925b8
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib_eio/fs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module Pi = struct
val rmdir : t -> path -> unit
val rename : t -> path -> _ dir -> path -> unit
val read_link : t -> path -> string
val symlink : t -> path -> link_to:path -> unit
val symlink : link_to:path -> t -> path -> unit
val pp : t Fmt.t
val native : t -> string -> string option
end
Expand Down
4 changes: 2 additions & 2 deletions lib_eio_linux/eio_linux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ end = struct
| Some fd2 -> Low_level.rename t.fd old_path fd2 new_path
| None -> raise (Unix.Unix_error (Unix.EXDEV, "rename-dst", new_path))

let symlink t path ~link_to =
Low_level.symlink link_to t.fd path
let symlink ~link_to t path =
Low_level.symlink ~link_to t.fd path

let pp f t = Fmt.string f (String.escaped t.label)

Expand Down
2 changes: 1 addition & 1 deletion lib_eio_linux/low_level.ml
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ let rename old_dir old_path new_dir new_path =
new_parent new_leaf
with Unix.Unix_error (code, name, arg) -> raise @@ Err.wrap_fs code name arg

let symlink link_to dir path =
let symlink ~link_to dir path =
with_parent_dir "symlinkat-new" dir path @@ fun parent leaf ->
try
eio_symlinkat link_to parent leaf
Expand Down
4 changes: 2 additions & 2 deletions lib_eio_linux/low_level.mli
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ val unlink : rmdir:bool -> dir_fd -> string -> unit
val rename : dir_fd -> string -> dir_fd -> string -> unit
(** [rename old_dir old_path new_dir new_path] renames [old_dir / old_path] as [new_dir / new_path]. *)

val symlink : string -> dir_fd -> string -> unit
(** [symlink link_to dir path] creates a new symlink at [dir / path] pointing to [link_to]. *)
val symlink : link_to:string -> dir_fd -> string -> unit
(** [symlink ~link_to dir path] creates a new symlink at [dir / path] pointing to [link_to]. *)

val pipe : sw:Switch.t -> fd * fd
(** [pipe ~sw] returns a pair [r, w] with the readable and writeable ends of a new pipe. *)
Expand Down
4 changes: 2 additions & 2 deletions lib_eio_posix/fs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ end = struct
| None -> invalid_arg "Target is not an eio_posix directory!"
| Some new_dir -> Err.run (Low_level.rename t.fd old_path new_dir) new_path

let symlink t path ~link_to =
Err.run (Low_level.symlink link_to t.fd) path
let symlink ~link_to t path =
Err.run (Low_level.symlink ~link_to t.fd) path

let open_dir t ~sw path =
let flags = Low_level.Open_flags.(rdonly + directory +? path) in
Expand Down
2 changes: 1 addition & 1 deletion lib_eio_posix/low_level.ml
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ let rename old_dir old_path new_dir new_path =

external eio_symlinkat : string -> Unix.file_descr -> string -> unit = "caml_eio_posix_symlinkat"

let symlink link_to new_dir new_path =
let symlink ~link_to new_dir new_path =
in_worker_thread "symlink" @@ fun () ->
Resolve.with_parent "symlink-new" new_dir new_path @@ fun new_dir new_path ->
let new_dir = Option.value new_dir ~default:at_fdcwd in
Expand Down
4 changes: 2 additions & 2 deletions lib_eio_posix/low_level.mli
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ val mkdir : mode:int -> dir_fd -> string -> unit
val unlink : dir:bool -> dir_fd -> string -> unit
val rename : dir_fd -> string -> dir_fd -> string -> unit

val symlink : string -> dir_fd -> string -> unit
(** [symlink link_to dir path] will create a new symlink at [dir / path]
val symlink : link_to:string -> dir_fd -> string -> unit
(** [symlink ~link_to dir path] will create a new symlink at [dir / path]
linking to [link_to]. *)

val readdir : dir_fd -> string -> string array
Expand Down
4 changes: 2 additions & 2 deletions lib_eio_windows/fs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ end = struct
with_parent_dir new_dir new_path @@ fun new_dir new_path ->
Err.run (Low_level.rename ?old_dir old_path ?new_dir) new_path

let symlink t path ~link_to =
let symlink ~link_to t path =
with_parent_dir t path @@ fun dirfd path ->
Err.run (Low_level.symlink link_to dirfd) path
Err.run (Low_level.symlink ~link_to dirfd) path

let close t = t.closed <- true

Expand Down
4 changes: 2 additions & 2 deletions lib_eio_windows/low_level.ml
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ let rename ?old_dir old_path ?new_dir new_path =

external eio_symlinkat : string -> Unix.file_descr option -> string -> unit = "caml_eio_windows_symlinkat"

let symlink old_path new_dir new_path =
let symlink ~link_to new_dir new_path =
with_dirfd "symlink-new" new_dir @@ fun new_dir ->
in_worker_thread @@ fun () ->
eio_symlinkat old_path new_dir new_path
eio_symlinkat link_to new_dir new_path

let lseek fd off cmd =
Fd.use_exn "lseek" fd @@ fun fd ->
Expand Down
5 changes: 3 additions & 2 deletions lib_eio_windows/low_level.mli
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ val mkdir : ?dirfd:fd -> ?nofollow:bool -> mode:int -> string -> unit
val unlink : ?dirfd:fd -> dir:bool -> string -> unit
val rename : ?old_dir:fd -> string -> ?new_dir:fd -> string -> unit

val symlink : string -> fd option -> string -> unit
(** [symlink link_to dir path] creates a new symbolic link [dir / path] pointing to [link_to] *)
val symlink : link_to:string -> fd option -> string -> unit
(** [symlink ~link_to dir path] will create a new symlink at [dir / path]
linking to [link_to]. *)

val readdir : string -> string array

Expand Down

0 comments on commit 8b925b8

Please sign in to comment.