commit
46ca15365a
3
Changes
3
Changes
|
@ -198,6 +198,9 @@ Working version
|
|||
(Guillaume Munch-Maccagnoni, review by David Allsopp, Damien Doligez and
|
||||
Gabriel Scherer)
|
||||
|
||||
- #8971: Add `Filename.null`, the conventional name of the "null" device.
|
||||
(Nicolás Ojeda Bär, review by Xavier Leroy and Alain Frisch)
|
||||
|
||||
### Other libraries:
|
||||
|
||||
- #1939, #2023: Implement Unix.truncate and Unix.ftruncate on Windows.
|
||||
|
|
|
@ -70,6 +70,7 @@ let generic_dirname is_dir_sep current_dir_name name =
|
|||
else trailing_sep (String.length name - 1)
|
||||
|
||||
module type SYSDEPS = sig
|
||||
val null : string
|
||||
val current_dir_name : string
|
||||
val parent_dir_name : string
|
||||
val dir_sep : string
|
||||
|
@ -88,6 +89,7 @@ module type SYSDEPS = sig
|
|||
end
|
||||
|
||||
module Unix : SYSDEPS = struct
|
||||
let null = "/dev/null"
|
||||
let current_dir_name = "."
|
||||
let parent_dir_name = ".."
|
||||
let dir_sep = "/"
|
||||
|
@ -128,6 +130,7 @@ module Unix : SYSDEPS = struct
|
|||
end
|
||||
|
||||
module Win32 : SYSDEPS = struct
|
||||
let null = "NUL"
|
||||
let current_dir_name = "."
|
||||
let parent_dir_name = ".."
|
||||
let dir_sep = "\\"
|
||||
|
@ -261,6 +264,7 @@ Quoting commands for execution by cmd.exe is difficult.
|
|||
end
|
||||
|
||||
module Cygwin : SYSDEPS = struct
|
||||
let null = "/dev/null"
|
||||
let current_dir_name = "."
|
||||
let parent_dir_name = ".."
|
||||
let dir_sep = "/"
|
||||
|
|
|
@ -118,6 +118,10 @@ val dirname : string -> string
|
|||
This function conforms to the specification of POSIX.1-2008 for the
|
||||
[dirname] utility. *)
|
||||
|
||||
val null : string
|
||||
(** [null] is ["/dev/null"] on POSIX and ["NUL"] on Windows. It represents a
|
||||
file on the OS that discards all writes and returns end of file on reads. *)
|
||||
|
||||
val temp_file : ?temp_dir: string -> string -> string -> string
|
||||
(** [temp_file prefix suffix] returns the name of a
|
||||
fresh temporary file in the temporary directory.
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
(* TEST
|
||||
*)
|
||||
|
||||
let () =
|
||||
let ic = open_in Filename.null in
|
||||
match input_char ic with
|
||||
| exception End_of_file -> close_in ic
|
||||
| _ -> assert false
|
|
@ -5,17 +5,11 @@ include unix
|
|||
** native
|
||||
*)
|
||||
|
||||
let null =
|
||||
if Sys.win32 then
|
||||
"NUL"
|
||||
else
|
||||
"/dev/null"
|
||||
|
||||
let () =
|
||||
let ic, _ as process =
|
||||
(* Redirect to null to avoid
|
||||
"The process tried to write to a nonexistent pipe." on Windows *)
|
||||
Printf.ksprintf Unix.open_process "echo toto > %s" null
|
||||
Printf.ksprintf Unix.open_process "echo toto > %s" Filename.null
|
||||
in
|
||||
assert
|
||||
(Unix.process_pid process = Unix.process_pid process);
|
||||
|
|
Loading…
Reference in New Issue