Boost logo

Boost Users :

From: JD (jean.daniel.michaud_at_[hidden])
Date: 2007-09-28 14:01:35


Hello,

   There is something I don't get with mapped_file from the IOStreams
library. Here is an example:

// Code snippet
#include <iostream>
#include <boost/iostreams/device/mapped_file.hpp>
#include <boost/iostreams/stream.hpp>

using namespace boost::iostreams;

int main(int argc, char **argv)
{
   if (argc != 2) return 1;

   try
   {
     stream <mapped_file_sink> out;
     mapped_file_params p(argv[1]);
     p.new_file_size = 1024 * sizeof (char);
     out.open(mapped_file_sink(p));
   }
   catch (const std::exception &e)
   {
     std::cout << e.what() << std::endl;
     return 2;
   }

   return 0;
}
// Code snippet

When compiled, the execution goes like:
c:\>test_shmem somefile

c:\>test_shmem somefile
failed setting file size: The handle is invalid.

    I tried without the new_file_size, I tried with a mapped_file... Is
there something I don't get? Why are we not able to open a file that
already exist?

   Thanks for your help.

JD


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net