Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let mb x = x * 1024 * 1024
- open Unix
- let _ =
- let filename = Sys.argv.(1) in
- let filesize = (stat filename).st_size in
- Printf.printf "%d\n" filesize;
- let restbytes = ref filesize in
- let strlen = mb 100 in
- let string = String.make strlen ' ' in
- let writesize = ref strlen in
- let fd = openfile filename [O_RDWR] 0o640 in
- while !restbytes > 0
- do
- writesize := (min !restbytes strlen);
- Printf.printf "restbytes: %d, writesize: %d\n" !restbytes !writesize;
- flush Pervasives.stdout;
- let num = write fd string 0 !writesize in
- restbytes := max 0 (!restbytes - num );
- Printf.printf "(just written: %d)\n" num;
- Printf.printf "restbytes: %d\n-----------\n" (* HERE I STHE ERROR! *)
- done;
- close fd
Add Comment
Please, Sign In to add comment