Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Unix.lseek versus Pervasives.pos
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-03-18 (06:54)
From: Basile STARYNKEVITCH <basile@s...>
Subject: [Caml-list] Unix.lseek versus Pervasives.pos
>>>>> "Shivkumar" == Shivkumar Chandrasekaran <> writes:

    Shivkumar> Hi, Currently I am trying to handle "LargeFiles" while
    Shivkumar> marshalling caml values and I have run into this
    Shivkumar> incidental problem (nothing to do with LargeFile). If I
    Shivkumar> open a file with "open_out_bin", write to it using
    Shivkumar> "output_value" 

You apparently forgot to flush the channel.

    Shivkumar> and then try to determine the position
    Shivkumar> in the file using "pos", I get the correct
    Shivkumar> value. However, if I use Unix.lseek thus

    Shivkumar> Unix.lseek (Unix.descr_of_out_channel fd_out) 0
    Shivkumar> Unix.SEEK_CUR

    Shivkumar> I get a different value (so far always 0) 

Forgetting to flush files on most systems should give similar
errors. Flushing files is not Ocaml specific, but a general issue (at
least under Unix, and probably Windows).

Perhaps the Ocaml manual could add as a hint to never forget flushing
files (but the tip might be there already), but this hint is very
basic & generic and is not Ocaml specific.



email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: