In Windows using VisualStudio 10 I've created a mapped_file as
char * OpenRW(std::string filePath )
{
<<fragment >>
mfp = new boost::iostreams::mapped_file_params(filePath);
mfp->mode = boost::iostreams::mapped_file::readwrite;
mfp->new_file_size = size;
mfp->offset = 0;
mf = new boost::iostreams::mapped_file(*mfp);
return mf->data();
}
I later close the file
void Close()
{
<<fragment>>
mf->close();
delete mfp;
delete mf;
}
And then want to reopen it
{
char* fileName = filePath.c_str();
int test = _open(fileName,_O_BINARY|_O_RDWR);
}
but test is returned -1 -- note that I am able to open the file _O_RDONLY. If I close the application and restart it, then I can read the file _O_RDWR (i.e. test is returned with a valid handle)
Is this a bug or am I doing something wrong?
Thanks Mark