Home > other >  About QT - memory mapping file, speaking, reading and writing
About QT - memory mapping file, speaking, reading and writing

Time:10-01

Recently written procedures, need to read and write operations of large files, use the traditional QFile found efficiency and its underground, so thought of memory mapping, and check the documents found QFile bring a map function, looked at half a day do not understand how to use, I am new, not previously exposed to the memory mapping, which can give I send a QT by using memory mapping example, appreciated, and you just need to a period of how to use the code, thank you, this text, through code how to read format memory mapping 410275.57 4207529.63 598.282 410275.90 4207542.12 616.827 410276.22 4207554.62 638.021 410276.54 4207567.11 656.056 410276.87 4207579.61 686.688 410277.19 4207592.10 701.087 QFile file (fileName); The file open (QIODevice: : ReadWrite); Uchar * FPR=file. Map (0, the file. The size ());//the map file, pay attention to the file here. The size () if is greater than the system of virtual memory, file block mapping//to actually block mapping for large files are generally, if (FPR) {//do something to FPR unmap (FPR); } the file. The close () saw this online content, not how to modify, please read the content with file mapping, the younger brother grateful

CodePudding user response:

Binary preservation, can change the file content to unify such a floating point number is a 32 bit, you use memory mapping is very easy to read, if is a text format, each number accounts for a byte, and also don't know how to points between Numbers and figures,

CodePudding user response:

You give the example fully shows the QFile usage, memory mapping file contents are directly available, if you still have questions, then have nothing to do with what read memory mapping and the file,

CodePudding user response:

Consult everybody, using the file mapping, calculate MD5 can a bit faster?

CodePudding user response:

FPR is equivalent to the starting address of the entire map, then which one do you want to read the address on this increase can be above, must be ASCII TXT read out, you need to turn a one byte, binary is better, you directly take address, give the corresponding double,

CodePudding user response:

FPR is a pointer uchar, what are you doing let qDebug output this pointer... And after unmap, even if you want to output a pointer corresponding content, do it at this time is already late, just like you to delete an object after go to call him

CodePudding user response:

If (FPR)
{
For (int r=0; R{
QDebug () & lt; Fpr++;
}
Unmap (FPR);
}
file.close()