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:

Qt Code:
  1. //make a new file with name in the directory
  2. file = new QFile(path +"\\"+ name);
  3. if(file->open(QIODevice::Append))
  4. fileName = name;// the file has been opened
  5. else
  6. return -1;
  7.  
  8. // make a text stream
  9. QTextStream stream( file );
  10.  
  11. // write the header
  12. stream.seek(POS_HEADER);
  13. stream << makeHeader();
  14.  
  15. // write the comments block
  16. QString comments("This is the standard comments block");
  17. stream.seek( POS_HEADER_COMMENT);
  18. stream << comments;
To copy to clipboard, switch view to plain text mode