How to make QFile read the whole line
-
@ManiRon It's not hard to fix:
const qint64 actualRead = file.read(fileData.data(),size_of_file);
-
could you replace
fileData = file.read(size_of_file);
with :fileData.resize(size_of_file); const auto actualRead = file.read(fileData.data(),size_of_file); Q_ASSERT(actualRead==size_of_file);
-
@ManiRon
OK, in that case it sounds right if it is followed by a "Nul". Personally I would put a comment into your code then to explain that is why you are seeking to byte #33.I don't see anything which would stop at a NUL in your code. What makes you think it is doing so? Are you just relying on the output of
qDebug("FILEDATA %s",fileData.data());
and thinking that shows it has not read past a NUL, that may be an artefact of howqDebug()
displays the data? Try debugging out the length of the data?No sir i checked the read by removing the NUL from the data in the file and i was able to see that it read the whole data and qDebug() was displaying the full data
This is the whole data when i removed the NUL : " WQA.,?E>t1?dWQA.,DE_??n1?d7be1526df618c0c4d1bab3959adb65ada9f20bd969493e532a7861d29bc6e698{TB.)?V1??n1?dS[H21?z7_??n1?d340819615bcd7cb87459cac37070456eb0af53716c1f0064c4771857728d3777 "
-
No sir i checked the read by removing the NUL from the data in the file and i was able to see that it read the whole data and qDebug() was displaying the full data
This is the whole data when i removed the NUL : " WQA.,?E>t1?dWQA.,DE_??n1?d7be1526df618c0c4d1bab3959adb65ada9f20bd969493e532a7861d29bc6e698{TB.)?V1??n1?dS[H21?z7_??n1?d340819615bcd7cb87459cac37070456eb0af53716c1f0064c4771857728d3777 "
-
@ManiRon said in How to make QFile read the whole line:
but thsi doest read the full data
What is the output of
qDebug() << actualRead << size_of_file;
?
-
@ManiRon said in How to make QFile read the whole line:
but thsi doest read the full data
What is the output of
qDebug() << actualRead << size_of_file;
?
-
@jsulm said in How to make QFile read the whole line:
size_of_file
Size = 194 .
I thought it was qdebug problem so i wrote the data read from the file to another file then also it remains the same as the data shown in the debug
-
@ManiRon
"What can we do" about what? You've spent the whole time claiming the read stops at the NUL, now you confirm it does not, so what's the problem? -
@ManiRon
"What can we do" about what? You've spent the whole time claiming the read stops at the NUL, now you confirm it does not, so what's the problem? -
@ManiRon said in How to make QFile read the whole line:
the size it specifies is correct but the data displayed is till the NUL
But I said that was just how
qDebug()
displays data. Read up about howqDebug()
displays strings/bytes, which may contain NUL. -
@ManiRon said in How to make QFile read the whole line:
the size it specifies is correct but the data displayed is till the NUL
But I said that was just how
qDebug()
displays data. Read up about howqDebug()
displays strings/bytes, which may contain NUL. -
@ManiRon
So read up howqDebug()
displays aQByteArray
(as well as aQString
)!!
Something even as old as https://www.qtcentre.org/threads/54236-qDebug-donsn-t-display-0x00?p=243053#post243053 will presumably do you..... -
Yes sir i can understand that it will take NUL as a terminate . Is there any way that i can store the full data along with the NUL
@ManiRon said in How to make QFile read the whole line:
Is there any way that i can store the full data along with the NUL
It is stored, just qDebug() stops it's output when it sees NUL. Take a look at the link @JonB provided above.
-
@ManiRon said in How to make QFile read the whole line:
Is there any way that i can store the full data along with the NUL
It is stored, just qDebug() stops it's output when it sees NUL. Take a look at the link @JonB provided above.
@Christian-Ehrlicher sir i checked the data are read from the file fully but the problem is the way i store . I tried to store it in a QByteArray variable, a char array Variable, a QString Variable but all are terminating when the data has a NUL Inbetween, Now its not the problem of qDebug .