472,353 Members | 1,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

seekg Concerns On Fragmented File

Tom
Given: A binary data file of records.

Task: Random access using seekg().

I've never found any documentation stating that the offset from begin
file marker is safe on a fragmented file. I've observed how binary
files are buffered in the past. But I have never tested against a
fragmented file. Perhaps I am paranoid or whatever. Maybe
fragmentation is no worse than changing tracks on the drive?

If the fragment starts at byte 50 and you offset 100 bytes from the
begin marker ... does the method scan for fragments? If so, is it any
faster than a sequential read method?

Any thoughts on the topic?

Please, no OT police comments. Thanks.

-- Tom
Feb 8 '06 #1
6 1629
Tom wrote:
Given: A binary data file of records.

Task: Random access using seekg().

I've never found any documentation stating that the offset from begin
file marker is safe on a fragmented file.
There is no concept of "fragmentation" in C++ (or C) streams. The
continuity of the stream is ensured by the host system.
I've observed how binary
files are buffered in the past. But I have never tested against a
fragmented file. Perhaps I am paranoid or whatever.
Could be. Do you feel being watched?
Maybe
fragmentation is no worse than changing tracks on the drive?
"Tracks on the drive" concept is absent from C++ as well.
If the fragment starts at byte 50 and you offset 100 bytes from the
begin marker ... does the method scan for fragments? If so, is it any
faster than a sequential read method?
Could be. Impossible to tell without clocking them both.
Any thoughts on the topic?
Beyond what I've just typed, not really. Seeking ahead in a file
that allows direct access is often faster than reading out all of
the intermediate bytes. But if the stream is truly sequential, then
seeking forward is _exactly_ like reading out all extraneous bytes,
at least that's IME.
Please, no OT police comments. Thanks.
You've just made one. Why should others be deprived of that right?

-- Tom


V
--
Please remove capital As from my address when replying by mail
Feb 8 '06 #2
"Tom" <Th********@earthlink.net> wrote in message
news:4q********************************@4ax.com...
Given: A binary data file of records.

Task: Random access using seekg().

I've never found any documentation stating that the offset from begin
file marker is safe on a fragmented file. I've observed how binary
files are buffered in the past. But I have never tested against a
fragmented file. Perhaps I am paranoid or whatever. Maybe
fragmentation is no worse than changing tracks on the drive?

If the fragment starts at byte 50 and you offset 100 bytes from the
begin marker ... does the method scan for fragments? If so, is it any
faster than a sequential read method?

Any thoughts on the topic?

Please, no OT police comments. Thanks.

-- Tom


Fragmentation and reading fragmentation happens at the OS level. Unless
you're writing your own disk driver you shouldn't have to worry about it.
As such, seekg is safe for fragmented files. If it wasn't safe, the OS
would be a piece of... well, you know, and unusable.

The OS itself is going to buffer the file read/writes independant of the
..exe's buffers in whatever language.

In other words, don't worry about it.
Feb 8 '06 #3

"Tom" <Th********@earthlink.net> wrote in message
news:4q********************************@4ax.com...
Given: A binary data file of records.

Task: Random access using seekg().

I've never found any documentation stating that the offset from begin
file marker is safe on a fragmented file. I've observed how binary
files are buffered in the past. But I have never tested against a
fragmented file. Perhaps I am paranoid or whatever. Maybe
fragmentation is no worse than changing tracks on the drive?

If the fragment starts at byte 50 and you offset 100 bytes from the
begin marker ... does the method scan for fragments? If so, is it any
faster than a sequential read method?

Any thoughts on the topic?

Please, no OT police comments. Thanks.


A (compliant) C++ implementation will ensure that all
stream operations treat a stream as a contiguous sequence
of characters, whether or not this is true at a 'lower level'
(e.g. OS, hardware, etc).

'File fragmentation' is an operating system issue,
not part of the 'abstract machine' defined by the
language.

-Mike
Feb 8 '06 #4
Tom
Victor, Jim, Mike -- thank you each for your input.

I've never been accused of being afraid to ask a question. I also have
zero fear of asking a dumb one, because I am so darn use to it by now.
:)

Every single day in this newsgroup I have learned. It's a very good
thing too.

There are many experts in here. Those who have more answers than
questions I salute you. I wonder ... is there some way to prompt the
gurus to just blog away in here about their C++ skills? Time is
precious and I am not trying to infringe on anyone's time ... but I
know I am not the only newb who'd be reading those blogs and
benefitting as well. hmmm, blog sounds a bit mundane. How about a
snazzy name: "C_log<xxx>"? Where "xxx" is the topic of your choice.
Easily identified and avoided by those so inclined, and also
highlighted for those who are anxious to read them. Excuse me,
sometimes I dream ..... Thanks again & good night.

- Tom
Feb 8 '06 #5
Tom wrote:

There are many experts in here. Those who have more answers than
questions I salute you. I wonder ... is there some way to prompt the
gurus to just blog away in here about their C++ skills?

I think the experts answering questions is more likely to result in
infodumps on topics that people are actually interested in. That's why
the question was asked in the first place.

Brian
Feb 8 '06 #6
On Wed, 08 Feb 2006 06:23:14 GMT, Tom <Th********@earthlink.net>
wrote:
I've never been accused of being afraid to ask a question. I also have
zero fear of asking a dumb one, because I am so darn use to it by now.
:)
"Keep on raging - to stop the aging." - Dale Carnegie :-)
Every single day in this newsgroup I have learned. It's a very good
thing too.
I used to do the same. It's harder nowadays with the clueless academic
NetCops.There used to be a lot more dicussion of C++ programming
instead of the same robotic answers repeated over and over. I can't
tell you how many "little gems" fell out of what would now be called
off-topic discussions. Not to say their wasn't a few egotistical
netcops around, but most just ignored them.
There are many experts in here. Those who have more answers than
questions I salute you. I wonder ... is there some way to prompt the
gurus to just blog away in here about their C++ skills?


This has happened from time to time. Herb Sutter used to do a, umm,
what was it called, Gotw: Gotcha of the Week? A little exercise
everyone could play with. He made a name for himself and now slaves
for the Evil Empire. "C++"/CLI... I don't know how he sleeps at night.
Oh wait, I guess I do: very, very richly that's how. I guess everyone
has their price. And no, I've never been offered mine yet. :-)

Plauger would/does reveal stuff on occasion while selling his wares. I
found Joseph Newcomer an absolute hoot. (Good Thing.) He was a
pragmatic Real Programmer (r)(tm) and didn't suffer the ludicrous
exercises of the Topic Nazis. (Probably why he doesn't come round
anymore.) Anyway...

I'm not sure there is anyone left here with the breadth of experience
and character that could do such a thing, and be the least bit
interesting. Most of the regulars here now are narrowly trained myopic
academics with little practical experience as far as I can tell. The
fact they can't figure out how to *skip a thread* they don't like
tells me all I need to know.

I think most of the people that could do it are now writing books or
are doing actual blogs. It is a great idea Tom. I don't want to be the
pessimist... anything could happen I guess.:-)

Behold! in Liberty's unclouded blaze, We lift our heads, a race of
other days. - Charles Sprague
Feb 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kapil Khosla | last post by:
Hi, I am trying to move the file pointer back to the original location, but not able to using seekg, can someone help ? Thanks, Kapil #include...
1
by: wtnt | last post by:
Hello. I've searched all over and haven't seen another thread with this problem. Please bear with me as I try to explain. thanks. :) I have...
2
by: Brian Ronk | last post by:
I'm having a strange error. I have a Debian stable server and I'm using gcc 3.3, but it looks like I have 3.4 installed as well. I recently made...
2
by: Assertor | last post by:
Hi, All. (VC++6.0) I found some strange thins when using getline() and seekg() of std::ifstream. After the file position of an open file was...
3
by: nomad5000 | last post by:
Hi I'm trying to read a textfile and print it's content twice to the std::cout but it won't work the second time. I think it has something to do with...
1
by: greek | last post by:
Hi I have to write a prg for the following question.. A file carsale_june.txt stores the number of small and medium-sized of cars sold in the...
12
by: Julian | last post by:
Hi, I am having problems with a function that I have been using in my program to read sentences from a 'command file' and parse them into commands....
1
by: fmufti | last post by:
I would like to check if the f_count is a valid position for seekg in the file or not. What I mean is if I pass a position to seekg and that does not...
33
by: Aaron Watters | last post by:
Why is the migration to py3k a concern? For example I have libraries which use string%dictionary substitution where the dictionary is actually an...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.