Boost logo

Boost Users :

Subject: Re: [Boost-users] [iostreams] - Using sparse Windows files
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2013-10-09 15:51:49

On 7 Oct 2013 at 16:00, Byrne, Kevin wrote:

> I am trying to write cross-platform Boost code that utilizes sparse files
> on Windows7 and FreeBSD. I already have Windows code that creates and
> accesses a sparse file. I am of the understanding that Boost code cannot
> create a Windows7 sparse file for me so I am trying to create the file
> using the Windows code and then replace my ReadFileEx() and WriteFileEx()
> with Boost streams. I have had luck with using iostreams::file to access an
> existing Windows sparse file but it fails when I have to read a sparse area
> thinking it is at the end of the file. I tried creating a stream using an
> existing HANDLE but was not successful in reading or writing file content.
> Before I proceed further I thought I would ask first if Boost is capable of
> using Windows7 sparse file technology. If it is capable I would appreciate
> some guidance on how. I have done a bit of searching on the web with not
> much helpful information.

Supposedly a file marked with the sparse flag appears like a
non-sparse file to normal file i/o functions. In theory, Boost
shouldn't notice a difference.

In practice, I'd guess this is not a well tested path of code. Even
in AFIO which is intended for this sort of thing, I haven't bothered
testing spare files. My main rationale: ReFS drops sparse file
support in favour of delayed allocation like is common on Linux, so
on Windows it's a dead end technology and is officially on track for

I agree this doesn't help you hugely right now. I suspect that
subclassing your own Boost.Iostreams adapter with the right sparse
files functions is likely your best course of action. Sorry.


Currently unemployed and looking for work.
Work Portfolio:

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at