Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:15:13+00:00 2026-06-11T10:15:13+00:00

How to truncate file to size N in ocaml ? I don’t see a

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:15:14+00:00Added an answer on June 11, 2026 at 10:15 am

    If you’re under Unix, you can use

    val Unix.truncate : string -> int -> unit
    

    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

    val really_input : in_channel -> string -> int -> int -> unit
    

    “really_input ic buf pos len reads len characters from channel ic, storing them in string buf, starting at character number pos. Raise End_of_file if the end of file is reached before len characters have been read. Raise Invalid_argument "really_input" if pos and len do not designate a valid substring of buf.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function which will create a file with fixed size in linux.
I just discovered that truncate {table} statements are not caught by most database triggers.
Trying to truncate some code here and running into a problem: <script type=text/javascript> $(function()
i want to truncate a number after decimal through a built in function in
Is there a function that can truncate or round a Double? At one point
I have had a template for some time which wrappers a C library FILE*.
I want to truncate 4th column of TSV file to given length in Unix.
I am trying to download a source code file from a web site which
In C#, I'm reading a moderate size of file (100 KB ~ 1 MB),
I need to truncate the amount of decimal places of my double value for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.