Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-24959

QFile::read() not report a file truncated during the reading

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 4.8.0, 5.2.0
    • Core: I/O
    • None
    • Linux, Qt 4.8, amd64

    Description

      Hello, in this kind of code:

      do
      {
      QBitArray block=file.read(blockSize);
      if(file.error()!=QFile::NoError)
      //error
      or
      char charArray[blockSize];
      qint64 readSize=file.read(charArray,blockSize);
      if(readSize==-1)
      //error
      }
      while(not the end);

      All error is detected (media problem, network share disconnected). But not if the file is truncated by other external program during the copy.
      Into the doc:

      However, reading past the end of the stream is considered an error, so this function returns -1 in those cases

      Bug with file on windows share and truncated by echo '' > file on the server. Bug too with truncated on same computer on linux environment.
      This truncate need be do by external program (here echo '' > file), during the file read by the Qt program. I use big file (3.8GB to have time to do echo '' > file)

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cnn Qt Core & Network
            alpha_one_x86 BRULE Herman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes