Hello all,
sorry if I'm making a silly mistake here, but I'm not sure what the best way is.
I'm making a file that has several blocks (at predefined positions). When I create the file, the blocks are not full (i.e. not contiguous). They will be filled later. So, I'd like to skip/extend the file to the position of the next block. Using a seek() and a write just appends and doesn't work.
how do I extend file?
thanks
K
below is the code:
//make a new file with name in the directory
file = new QFile(path
+"\\"+ name
);
fileName = name;// the file has been opened
else
return -1;
// make a text stream
// write the header
stream.seek(POS_HEADER);
stream << makeHeader();
// write the comments block
QString comments
("This is the standard comments block");
stream.seek( POS_HEADER_COMMENT);
stream << comments;
//make a new file with name in the directory
file = new QFile(path +"\\"+ name);
if(file->open(QIODevice::Append))
fileName = name;// the file has been opened
else
return -1;
// make a text stream
QTextStream stream( file );
// write the header
stream.seek(POS_HEADER);
stream << makeHeader();
// write the comments block
QString comments("This is the standard comments block");
stream.seek( POS_HEADER_COMMENT);
stream << comments;
To copy to clipboard, switch view to plain text mode
Bookmarks