ThunkIoDisk.MakeSourceinclude sig ... endtype file_object = private {file_origin : string;is_local_file : bool;open_for_writing : unit ->
[ `Error of string | `IsDirectory of directory_object | `Node of Int64.t ]
M.t;open_for_reading : unit ->
[ `Error of string | `IsDirectory of directory_object | `Node of Int64.t ]
M.t;read_some : Int64.t ->
[ `Bytes of bytes * int * int | `Eof | `Error of string ] M.t;write_all : Int64.t ->
string ->
int ->
int ->
[ `Error of string | `WroteBytes ] M.t;close : Int64.t -> unit M.t;read_all : unit ->
[ `Content of string | `Error of string | `ExceededSizeLimit of int64 ] M.t;prepare_as_copy_destination : unit -> [ `Error of string | `Ready ] M.t;delete_file : unit -> [ `Deleted | `Error of string ] M.t;checksum_file : strip_carriage_returns:bool ->
algo:[ `Sha1 | `Sha256 ] ->
unit ->
[ `Checksum of string * Int64.t | `Error of string ] M.t;}and directory_object = private {dir_origin : string;create_directory : unit -> [ `Created | `Error of string ] M.t;delete_directory : unit -> [ `Deleted | `Error of string ] M.t;zip_directory : ?intermediate:unit ->
staging_dir:directory_object ->
unit ->
[ `Error of string | `ZipFile of file_object ] M.t;spawn_in_directory : command:MlFront_Core.FilePath.t ->
args:string list ->
envmods:MlFront_Core.EnvMods.t ->
stdout:file_object ->
stderr:file_object ->
unit ->
[ `Error of string | `Exited of int | `Signaled of int | `Stopped of int ]
M.t;interactive_shell_in_directory : ?promptname:string ->
envmods:MlFront_Core.EnvMods.t ->
unit ->
[ `Error of string | `Exited of int | `Signaled of int | `Stopped of int ]
M.t;}val generic_file :
origin:string ->
is_local_file:bool ->
open_for_writing:
(unit ->
[ `Error of string
| `IsDirectory of directory_object
| `Node of Int64.t ]
M.t) ->
open_for_reading:
(unit ->
[ `Error of string
| `IsDirectory of directory_object
| `Node of Int64.t ]
M.t) ->
read_some:
(Int64.t -> [ `Bytes of bytes * int * int | `Eof | `Error of string ] M.t) ->
write_all:
(Int64.t -> string -> int -> int -> [ `Error of string | `WroteBytes ] M.t) ->
close:(Int64.t -> unit M.t) ->
read_all:
(unit ->
[ `Content of string | `Error of string | `ExceededSizeLimit of int64 ]
M.t) ->
prepare_as_copy_destination:(unit -> [ `Error of string | `Ready ] M.t) ->
delete_file:(unit -> [ `Deleted | `Error of string ] M.t) ->
checksum_file:
(strip_carriage_returns:bool ->
algo:[ `Sha1 | `Sha256 ] ->
unit ->
[ `Checksum of string * Int64.t | `Error of string ] M.t) ->
unit ->
file_objectval generic_dir :
origin:string ->
create_directory:(unit -> [ `Created | `Error of string ] M.t) ->
delete_directory:(unit -> [ `Deleted | `Error of string ] M.t) ->
zip_directory:
(?intermediate:unit ->
staging_dir:directory_object ->
unit ->
[ `Error of string | `ZipFile of file_object ] M.t) ->
spawn_in_directory:
(command:MlFront_Core.FilePath.t ->
args:string list ->
envmods:MlFront_Core.EnvMods.t ->
stdout:file_object ->
stderr:file_object ->
unit ->
[ `Error of string
| `Exited of int
| `Signaled of int
| `Stopped of int ]
M.t) ->
interactive_shell_in_directory:
(?promptname:string ->
envmods:MlFront_Core.EnvMods.t ->
unit ->
[ `Error of string
| `Exited of int
| `Signaled of int
| `Stopped of int ]
M.t) ->
unit ->
directory_objectval read_all :
file_object ->
[ `Content of string | `Error of string | `ExceededSizeLimit of int64 ] M.tval copy :
src:file_object ->
dest:file_object ->
unit ->
[ `Copied
| `DestinationIsDirectory of directory_object
| `Error of string
| `SourceIsDirectory of directory_object ]
M.tval copy_or_fail :
src:file_object ->
dest:file_object ->
on_error:(string -> 'a M.t) ->
'a M.t ->
'a M.tval copy_but_error_if_dest_is_dir :
src:file_object ->
dest:file_object ->
unit ->
[ `Copied | `Error of string | `SourceIsDirectory of directory_object ] M.tval checksum_file :
?strip_carriage_returns:unit ->
algo:[ `Sha1 | `Sha256 ] ->
file_object ->
[ `Checksum of string * Int64.t | `Error of string ] M.tval replace_all_bytes :
file_object ->
bytes ->
int ->
int ->
[ `Error of string | `IsDirectory of directory_object | `WroteBytes ] M.tval replace_all_string :
file_object ->
string ->
int ->
int ->
[ `Error of string | `IsDirectory of directory_object | `WroteBytes ] M.tval spawn_in_directory :
command:MlFront_Core.FilePath.t ->
args:string list ->
cwd:directory_object ->
envmods:MlFront_Core.EnvMods.t ->
stdout:file_object ->
stderr:file_object ->
unit ->
[ `Error of string | `Exited of int | `Signaled of int | `Stopped of int ]
M.tval interactive_shell_in_directory :
?promptname:string ->
envmods:MlFront_Core.EnvMods.t ->
cwd:directory_object ->
unit ->
[ `Error of string | `Exited of int | `Signaled of int | `Stopped of int ]
M.tval copy_file_or_dir_to_file_and_sha256_or_fail :
?intermediate:unit ->
src:file_object ->
dest:file_object ->
staging_dir:directory_object ->
on_error:(string -> 'b M.t) ->
(string -> int64 -> 'b M.t) ->
'b M.tmemory_limit.
16 MiB is the maximum on 32-bit OCaml platforms for a single string. However, js_of_ocaml uses maximum JavaScript string size which is undocumented but at least 2^51.
We'll use 2^31 - 1 as limit for now as that is the memory bound for 32-bit signed C integers.
disk_file origin creates a new file object that reads from the disk from the file origin. The file is read synchronously, so use a different file object implementation for asynchronous reads.