Boost logo

Boost Users :

Subject: [Boost-users] boost basic_file open
From: Afshin Amighi (afshinamighi_at_[hidden])
Date: 2010-07-26 10:23:09


Hello ,
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;
}
}



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