Bind different files program Qt
-
@jsulm it's strange but when i bind files in linux works and when i compile for windows bind files but not seem's to do the functions that i use.
-
@jsulm But how i can put the size of my trama in my stub if i dont know the size??? Because i can change in my binder but i must to put the size of my trama to read the files.
-
@RIVOPICO I don't understand the problem. If you put something into QByteArray then that array knows its size and you can get it calling size() method as shown before.
-
@jsulm yeah but if you check in the stub you will see these lines:
archivoStub->seek(archivoStub->size() - 1024); trama = archivoStub->read(1024);
I'm extracting my trama and then i read it. I can put trama size in my binder. But in my stub how i can read this trama? Because if i put 1024 i know the size and i can extract this trama and then read it. But if i dont know my trama how my stub can read my trama? Because if i dont know where is the trama will show me list outrange. So in other words if i want to read my trama i must to know this size of my trama or include something in my stub to get the size of this trama.
Yeah i know but im trying to say that i seek my trama, i extract my trama because i know the size in my case i only put with 1024 bytes but i dont know if the size is more big (undefined)how my stub can know this size of trama? so i think my stub can't know the size of my trama.
-
This post is deleted! -
@RIVOPICO Well, if the size of what you want to read is variable then you need to specify a format. For example you can first put an integer into your file specifying the size and then trama of that size, then again size and trama and so on:
SIZE1TRAMA1SIZE2TRAMA2
Then you know how to interpret what you're reading.
For such stuff it is better to use QDataStream instead of QFile directly.QFile file("file.dat"); file.open(QIODevice::ReadOnly); QDataStream in(&file); int size; // Do the following in a loop until finished reading in >> size; char buffer[BUFFER_SIZE]; in.readRawData(buffer, size);
-
@jsulm yeah this i was trying. because if i put the size and then i can read this size, i can read my trama too. But i have some doubts, this code is for reading or for including the size of my data? sorry for all!
-
@RIVOPICO Reading
-
@jsulm i was thinking to include other trama with the size of my real trama and then get the size of the real trama because my other trama has defined size. Other way will be with a format but i dont know if i can seek one file with format or how i can read this file included in my all files. Anyways i think int number doesn't take many space to be a problem, i think.
-
@RIVOPICO Is there a reason why you keep deleting your postings? Makes it pretty hard to follow the thread.