[comp.sys.mac] Finding the current position of an open file--again

mike@george.uh.edu (Mike Frederick) (03/09/90)

In article <5743.25f51321@george.uh.edu>, mike@george.uh.edu (Mike Frederick) writes:
> If I know the ioRefNum of an open file, how do I find the current file
> position?  In other words, how can I know where the read will be in an open
> file?
> 
> Mike Frederick
> MIKE@UH.EDU

The answers (thanks!) that I have received so far reminded me why I almost
never post questions; I can't seem to get the context completely right.
Therefore, let me try again:

I am attempting to learn exactly how a program (for which I do not have source)
works.  I have trapped a READ (xA002), and I can see the paramBlock with the
ioRefNum in it.  Using only MacBugs, how can I get to the file mark?  I see
something called a File Control Block which is kept in memory for each open
file, and it a field called fcbCrPs which is described as "mark".  Is this
what I want, and how do I get to the correct FCB from the paramBlock?

russotto@eng.umd.edu (Matthew T. Russotto) (03/09/90)

In article <5753.25f634f1@george.uh.edu> mike@george.uh.edu (Mike Frederick) writes:

>I am attempting to learn exactly how a program (for which I do not have source)
>works.  I have trapped a READ (xA002), and I can see the paramBlock with the
>ioRefNum in it.  Using only MacBugs, how can I get to the file mark?  I see
>something called a File Control Block which is kept in memory for each open
>file, and it a field called fcbCrPs which is described as "mark".  Is this
>what I want, and how do I get to the correct FCB from the paramBlock?

Try the 'file' dcmd that comes with the later (post- 6.0) MacsBugs' It will
tell you all you want to know.  And if it doesnt, use the 'dm' command
with the template for FCBs on the address the 'file' command gives you.
The new MacsBug is GREAT!
--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
][, ][+, ///, ///+, //e, //c, IIGS, //c+ --- Any questions?

lefty@twg.com (David N. Schlesinger) (03/13/90)

In article <5753.25f634f1@george.uh.edu> mike@george.uh.edu (Mike 
Frederick) writes:
> I have trapped a READ (xA002), and I can see the paramBlock with the
> ioRefNum in it.  Using only MacBugs, how can I get to the file mark?  I see
> something called a File Control Block which is kept in memory for each open
> file, and it a field called fcbCrPs which is described as "mark".  Is this
> what I want, and how do I get to the correct FCB from the paramBlock?

Yes, the fcbCrPs field _is_ what you want.  To find the appropriate FCB, 
take the ioRefNum from the parameter block and add it to the address stored at the low-memory global FCBsPtr (at location 0x34E).  This will get you a pointer to the appropriate FCB.

Hope this helps,

Lefty

|<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>|
|           David N. Schlesinger   ||   "When I have nothing to say,       |
|           The Wollongong Group   ||    my lips are sealed;               |
| Internet: Lefty@twg.com          ||    say something once,               |
| POTS:     415/962-7219           ||    why say it again?" -- David Byrne |
|<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>|