English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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 <shiv@ece.ucsb.edu> 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.



Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
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 caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners