How to truncate file to size N in ocaml ?
I don’t see a function in Pervasive. The closest thing is “open_trunc” flag which I’m not really sure what it does.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re under Unix, you can use
It “runcates the named file to the given size”.
But this function is not implemented in the Windows version of OCaml (or more precisely, it is not emulated).
If you’re under Windows and want to emulate it, you might be interested in
“
really_input ic buf pos lenreadslencharacters from channelic, storing them in stringbuf, starting at character numberpos. RaiseEnd_of_fileif the end of file is reached beforelencharacters have been read. RaiseInvalid_argument "really_input"ifposandlendo not designate a valid substring ofbuf.”