I am very new in boost file system and simply I wrote a sample to use boost file system. I need a file descriptor for both read and write. When I implement below code for "sink" and "source" files, they work. But I don't understand why I couldn't open a basic_file object to read and write. Any comment is appreciated. Thanks in advance.
void test_boost2(){
long long size=5*1024*1024;
char buffer [L_tmpnam];
const char* prefix = "c1t";
string tempPath(archive::tmpdir());
filesystem::path path(tempPath);
filesystem::space_info spi(space(path));
strcpy(buffer,prefix);
if( spi.free > size * 3/2 && tmpnam (buffer+sizeof(prefix)-1) != NULL){
buffer[sizeof(prefix)-1]='_';
path/=buffer;
boost::iostreams::basic_file<char> *tmpFile= new basic_file<char>(path.string());
tmpFile->open(path.string());
if(tmpFile->is_open()){
long long p=size-DATA_SIZE-2;
tmpFile->seek(p,ios_base::beg);
tmpFile->close();
}
delete tmpFile;
}
}