[net.micro.mac] How to find LaserWriter file

dolf@uva.UUCP (Dolf Starreveld) (04/09/86)

Sender:


I'm writing a program from which I have to access the current LaserWriter
file, because I need some resources from that file. I would like this program
to work on old (128K/512K) and new MacIntoshes (Plus) and on pre 3.0 and post
3.0 Systems files, as well as under MFS and HFS.

My idea was:
	1) Look at STR resource ID -8192 in the System file to find out
	   what the currently selected printer is.
	2) Use the name contained in the resource as the name of the file
	   with the printer driver. (Is this the correct way of determing
	   the name of the LW file?)
Problem:
	Generally my application won't be in the System Folder, nor will it
	be on the same disk as the System Folder. Therefore calling OpenResFile
	won't always result in actually opening the LaserWriter file. To 
	accomplish this I need to no the vRefNum of the volume the LW file
	is located on.
Problem:
	How do I find out on which volume this file is on without doing
	an exhaustive search of all files/directories?
Idea:
	Use HomeResFile on the STR (-8192) resource to get an ioRefNum for
	the System file. Use that refnum to locate the corresponding
	vRefNum (or on HFS a wdRefNum). Assume that the file whose name
	I took from the STR (-8192) resource is in the same folder as the
	System file.
	Temporarily switch to that volume/folder, call OpenresFile, switch
	back, done.
	This requires a routine which will link an ioRefNum corresponding to
	an open access path to a vRefNum.
	Is there a better way to do this ?
	The HFS software provides such a routine, called "GetVRefNum", but
	what to do on a Mac where such a routine is not present?
Idea:
	Find the file's FCB, use an entry in the FCB to find the corresponding
	VCB and there you can find the vRefNum.
Problem:
	How is an ioRefNum linked to an FCB. The FCB list can be scanned, but
	an FCB does not contain the correspondings file's ioRefNum.
Idea:
	Might it be that the ioRefNum can be used as an index in the FCB list ?

Any answer to the questions posed above would be of great value to me.
Also source code to emulate a routine such as PBGetFCBInfo which works
on HFS only would be appreciated.

The work I'm doing and need this for, ultimately has to do with spooling
of LaserWriter output and it is quite likely that the software will be
put in the public domain so ...

I am using AZTEC C68K 1.06G so I would appreciate C code. However, Pascal,
assembly or any other language would also be appreciated, as long as I get
some useful info.


			Dolf Starreveld
			Computer Science Department, University of Amsterdam


Usenet:			{seismo, philabs, decvax}!mcvax!dolf@{uva,fvi}
Normal mail:		Dolf Starreveld
			Computer Science Department
			University of Amsterdam
			Kruislaan 409
			NL 1098 SJ  Amsterdam
			The Netherlands
-- 
			Dolf Starreveld
			Computer Science Department, University of Amsterdam


Usenet:			{seismo, philabs, decvax}!mcvax!dolf@{uva,fvi}
Normal mail:		Dolf Starreveld
			Computer Science Department
			University of Amsterdam
			Kruislaan 409
			NL 1098 SJ  Amsterdam
			The Netherlands

darin@ut-dillo.UUCP (Darin Adler) (04/11/86)

In article <42@uva.UUCP>, dolf@uva.UUCP (Dolf Starreveld) writes:
> My idea was:
> 	1) Look at STR resource ID -8192 in the System file to find out
> 	   what the currently selected printer is.
> 	2) Use the name contained in the resource as the name of the file
> 	   with the printer driver. (Is this the correct way of determing
> 	   the name of the LW file?)
> Problem:
> 	Generally my application won't be in the System Folder, nor will it
> 	be on the same disk as the System Folder. Therefore calling OpenResFile
> 	won't always result in actually opening the LaserWriter file. To 
> 	accomplish this I need to no the vRefNum of the volume the LW file
> 	is located on.

(Dolf then mentions Aztec C)

The System Folder is always open as a Working Directory under HFS.  That
means that there is always a WDRefNum (or vRefNum) that identifies it, under
MFS *or* HFS.  That vRefNum is stored in a low-memory global, "BootDrive".
Contrary to what that misleading name may have you believe, this contains
the WDRefNum (or vRefNum) of the System Folder.  I do not program much in C,
but I think that something like this should do the trick:

#define BootDrive (* (short *) 0x210)

Good Luck,
-- 
Darin Adler	...!ut-sally!ut-dillo!darin	darin@dillo.CC.UTEXAS.EDU

"...'cause they don't go for what's in the book and that makes 'em bad..."
								Frank Zappa