seek

QFile seek performance

回眸只為那壹抹淺笑 提交于 2019-12-01 11:33:00
It appears that QFile when working with a regular file (not a special Linux I/O device file) is random access, meaning that a seek operation has constant-time complexity O(1). However, I haven't been able to confirm this. In general, when jumping to a specific position in a file (for writing or reading), does std::fstream and QFile provide constant-time running time complexity? The short answer is "yes, for practical purposes". The long answer is... It's complicated. Seeking on a file stream ultimately calls lseek() on the underlying file descriptor, whose performance depends on the kernel.

Question about file seeking position

做~自己de王妃 提交于 2019-12-01 09:44:33
My previous Question is about raw data reading and writing, but a new problem arised, it seems there is no ending.... The question is: the parameters of the functions like lseek() or fseek() are all 4 bytes. If i want to move a span over 4G, that is imposible. I know in Win32, there is a function SetPointer(...,Hign, Low,....) , this pointers can generate 64 byte pointers, which is what i want. But if i want to create an app in Linux or Unix (create a file or directly write the raw drive sectors), How can I move to a pointer over 4G? Thanx, Waiting for your replies... The offset parameter of

Question about file seeking position

僤鯓⒐⒋嵵緔 提交于 2019-12-01 08:53:18
问题 My previous Question is about raw data reading and writing, but a new problem arised, it seems there is no ending.... The question is: the parameters of the functions like lseek() or fseek() are all 4 bytes. If i want to move a span over 4G, that is imposible. I know in Win32, there is a function SetPointer(...,Hign, Low,....) , this pointers can generate 64 byte pointers, which is what i want. But if i want to create an app in Linux or Unix (create a file or directly write the raw drive

QFile seek performance

偶尔善良 提交于 2019-12-01 08:22:30
问题 It appears that QFile when working with a regular file (not a special Linux I/O device file) is random access, meaning that a seek operation has constant-time complexity O(1). However, I haven't been able to confirm this. In general, when jumping to a specific position in a file (for writing or reading), does std::fstream and QFile provide constant-time running time complexity? 回答1: The short answer is "yes, for practical purposes". The long answer is... It's complicated. Seeking on a file

Write function not using the seekp value

白昼怎懂夜的黑 提交于 2019-12-01 06:31:24
I'm trying to use C++ to write an entry in a specific place in a file so basicly I have ofstream ofs("file.dat", ios::binary | ios::app); ofs.seekp(220, ios::beg); ofs.write((char *)&i, sizeof(i)); But no matter what I do it always write at the end of the file. I suppose this is related to iso::app because according to the documentation app (append) Set the stream's position indicator to the end of the stream before each output operation But if I use ate or nothing it always erases the content of the file. Any help would be great :) Yes, it's the ios::app that's causing this behaviour. Replace

JWPlayer Prevent SKipping forward unless already watched

拜拜、爱过 提交于 2019-12-01 05:52:57
I'm using JWPlayer 5.4 and it's setup on the page using the javascript API. What I'd like to do is make it so that users can fastforward/rewing via the seek bar ONLY if they have already played that part of the video. So, if a user is watching the video for the first time they can't skip beyond the current position, however they can seek forward and back behind where the video played up until. I'm struggling with the API onTime events etc. to try and work out the Math to make this work. Does anyone know how this could be done. Thanks mal I found this a while back, probably on the JWplayer

Can I seek a position beyond 2GB in C using the standard library?

拜拜、爱过 提交于 2019-12-01 05:14:30
I am making a program that reads disk images in C. I am trying to make something portable, so I do not want to use too many OS-specific libraries. I am aware there are many disk images that are very large files but I am unsure how to support these files. I have read up on fseek and it seems to use a long int which is not guaranteed to support values over 2 31 -1. fsetpos seems to support a larger value with fpos_t but an absolute position cannot be specified. I have also though about using several relative seeks with fseek but am unsure if this is portable. How can I support portably support

Perl seek function

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 15:42:28
问题 This problem was solved. Thank you very much. My question and the solution I am using is stated below. Question: open IN, "<./test.txt"; seek(IN,10,0); read IN, $temp, 5; seek(IN,20,0); close(IN); The situation is that, my handle will start at position 0. After the first seek function, my file handle will at position 10. After I read, my handle will at position 15. At this moment, I seek again. Then the program will seek from the beginning or from position 20. My question is that is there

Python file.tell gives wrong value location

南楼画角 提交于 2019-11-30 15:32:34
I am trying to extract a number of locations from an existing file using Python. This is my current code for extracting the locations: self.fh = open( fileName , "r+") p = re.compile('regGen regPorSnip begin') for line in self.fh : if ( p.search(line) ): self.porSnipStartFPtr = self.fh.tell() sys.stdout.write("found regPorSnip") This snippet is repeated a number of times (less the file open) with different search values, and seems to work: I get the correct messages, and the variables have values. However, using the code below, the first write location is wrong, while subsequent write

Perl seek function

牧云@^-^@ 提交于 2019-11-30 15:31:22
This problem was solved. Thank you very much. My question and the solution I am using is stated below. Question: open IN, "<./test.txt"; seek(IN,10,0); read IN, $temp, 5; seek(IN,20,0); close(IN); The situation is that, my handle will start at position 0. After the first seek function, my file handle will at position 10. After I read, my handle will at position 15. At this moment, I seek again. Then the program will seek from the beginning or from position 20. My question is that is there anyway for me to do searching in a file so that I do not need to search from the starting point of the