$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] [iostreams] Truncate file?
From: Adam Nielsen (a.nielsen_at_[hidden])
Date: 2010-03-28 03:53:44
Hi all,
I'm trying to work out how to chop some data off the end of a file once I have
finished modifying it. I'm not sure how to adjust the file size in a portable
fashion, and although I'm using boost::iostreams I can't see how to either set
the size of the underlying stream or how to otherwise indicate where the
stream should end.
Is this possible with boost:iostreams? If not, is there another portable way
to remove data from the end of a file, causing its size to shrink?
All I can find around the place are calls to ftruncate() and the like, but I
would like my program to work on Windows as well as Linux, and hopefully other
platforms too.
Many thanks,
Adam.