Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,7 @@
let load_file f =
let ic = open_in f in
let n = in_channel_length ic in
let s = Bytes.create n in
really_input ic s 0 n;
close_in ic;
(s)

View file

@ -0,0 +1 @@
(Bytes.unsafe_to_string s)

View file

@ -0,0 +1,2 @@
type big_string =
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t

View file

@ -0,0 +1,9 @@
let load_big_file filename =
let fd = Unix.openfile filename [Unix.O_RDONLY] 0o640 in
let len = Unix.lseek fd 0 Unix.SEEK_END in
let _ = Unix.lseek fd 0 Unix.SEEK_SET in
let shared = false in (* modifications are done in memory only *)
let bstr = Bigarray.Array1.map_file fd
Bigarray.char Bigarray.c_layout shared len in
Unix.close fd;
(bstr)

View file

@ -0,0 +1,7 @@
let () =
let bstr = load_big_file Sys.argv.(1) in
let len = Bigarray.Array1.dim bstr in
for i = 0 to pred len do
let c = bstr.{i} in
print_char c
done