[comp.sys.mac.programmer] Help with file manager

jroberts@mipos3.intel.com (Joe Roberts) (01/07/89)

Hi folks,

    I am a new poster to this newsgroup. I have read the articles in this
    newsgroup and have enjoyed them immensely.

    I want to write a label making program for the Mac. What I would like
    to know is a simple way of getting a directory listing of a diskette.
    I would like to do this from a C or Pascal program.  I have looked in
    Inside MacIntosh II and have found some low-level ROM calls (FileManager).
    However, finding them in IM II does not mean I understand them. Could some
    helpful soul out there tell me how to use them. ADVthanksANCE.
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Disclaimer? We don't need no stinkin' disclaimers!!!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                            "I would use a rock if I thought it
Joe Roberts                                  would protect my client. Whatever
Intel/Santa Clara, CA                        works!" - Jon Sable Freelance
Ph. (408) 765-4093
{hplabs,decwrl,oliveb,amdcad}!intelca!mipos3!jroberts

bob@accuvax.nwu.edu (Bob Hablutzel) (01/07/89)

>    I am a new poster to this newsgroup. I have read the articles in this
>    newsgroup and have enjoyed them immensely.

Welcome.

>    I want to write a label making program for the Mac. What I would like
>    to know is a simple way of getting a directory listing of a diskette.
>    I would like to do this from a C or Pascal program.  I have looked in
>    Inside MacIntosh II and have found some low-level ROM calls (FileManager).
>    However, finding them in IM II does not mean I understand them. Could some
>    helpful soul out there tell me how to use them. ADVthanksANCE.

Ignore Inside Mac II. Due to senility, the poor thing is living in a kinder,
gentler, rose-tinted past. (With regard to the file manager, I mean).

Nope, run right out and get Inside Macintosh IV. If you think the file manager
was confusing in Inside Macintosh II, just wait until you see Inside Mac IV.

However, there is hope. Get yourself a copy of Tech Note #68, which has,
in Pascal and C, a routine which scans an entire directory. If this note is 
not available to you, drop me a line, and I'll mail it to you. (Binhexed).

(By the way, don't dispair. The file manager does take some getting used to,
I'll admit, but once you get the hang of it, it's quite easy to handle.
Tech Note 68 will be a fairly good introduction).

Bob Hablutzel		BOB@NUACC.ACNS.NWU.EDU
Disclaimer:		After VMS RMS XAB fields, the file manager is easy...

jroberts@mipos3.intel.com (Joe Roberts) (01/10/89)

In article <10050061@accuvax.nwu.edu> Bob Hablutzel writes:
>However, there is hope. Get yourself a copy of Tech Note #68, which has,
>in Pascal and C, a routine which scans an entire directory. If this note is 
>not available to you, drop me a line, and I'll mail it to you. (Binhexed).

BOY! What timing. This tech note just arrived with the new batch of Tech
notes in comp.binaries.mac. Thank you very much for the information.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Disclaimer? We don't need no stinkin' disclaimers!!!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                            "I would use a rock if I thought it
Joe Roberts                                  would protect my client. Whatever
Intel/Santa Clara, CA                        works!" - Jon Sable Freelance
Ph. (408) 765-4093
{hplabs,decwrl,oliveb,amdcad}!intelca!mipos3!jroberts

lasky@iris.ucdavis.EDU (Ty Lasky) (01/15/91)

I need some help with the File Manager. I need a fairly permanent way to
refer to data files, i.e. a way that works between reboots. It is my
understanding that the best way to do this is a combination of a volume
name, working directory ID, and a file name. I have a few questions about this.

1.  If I am using SFGetFile to allow the user to select a file, then I
believe I have the name and the volume reference number (or is it the
working directory ID?). Now, how do I get the volume name?

2.  How do I find out the drive number of the current default volume? I
know that the hard disk is volume 1, and externals are 2, but how do I
REALLY find out what a drive number is? If I know the drive number, I
can then just use GetVInfo to find out any other info that I want to know.

3.  Assuming that I have a volume name, file name, and working directory
ID, how do I then set the volume to that volume, and then set to the
correct directory? I know how to use SetVol to set the directory, and
right after calls to SFGetFile and SFPutFile, but I can't seem to set
the default directory to one on  another drive in a simple test program.

4.  Inside Mac, and other references, keep saying that routines like
GetVol return either the volume name OR the directory name. Which is it?
Under what circumstances? This is really not clear to me. Is it
something to do with MFS vs. HFS?

Am I on the right track here? Please send me any responses by e-mail, as
I can't really get to the group right now.

Thanks in advance,

Ty A. Lasky
lasky@iris.ucdavis.edu

An aspiring Mac programmer.

Ken.Knight@f421.n109.z1.fidonet.org (Ken Knight) (01/16/91)

lasky@iris.ucdavis.EDU (Ty Lasky) Asks:
>1.  If I am using SFGetFile to allow the user to select a file, then I
>believe I have the name and the volume reference number (or is it the
>working directory ID?). Now, how do I get the volume name?
 
SFGetFile() gives you a volume reference number. What you then need is
the working directory ID which you can get with a call to GetWDInfo().
Like this:
  err = GetWDInfo(0,&(reply.vRefNum),&dirID,&procID);
  if (err == noErr) {
     err = HOpen(reply.vRefNum,dirId,reply.fName,permission,refNum);
     .... /* Permission is the read/write access to want for the file.
*/
     .... /* do you thing. */
  }
 
All these routines are documented in tech note #218.
 
>3.  Assuming that I have a volume name, file name, and working
>directory
>ID, how do I then set the volume to that volume, and then set to the
>correct directory? I know how to use SetVol to set the directory, and
>right after calls to SFGetFile and SFPutFile, but I can't seem to set
>the default directory to one on  another drive in a simple test
>program.
I don't have the hard answer for this one. However, Apple DTS has some
source code out there that should be of use to you. It shows you how to
change current default directories and I think that is what you want.
>4.  Inside Mac, and other references, keep saying that routines like
>GetVol return either the volume name OR the directory name. Which is
>it?
>Under what circumstances? This is really not clear to me. Is it
>something to do with MFS vs. HFS?
Routines like GetVol vary what they return depending on how you fill in
that annoying parameter block. I'd suggest you you the high level
routines I mentioned above that are described in Technote #218.
 
Hope that helps.
  ** Ken **


--  

        Ken Knight, Ken.Knight@f421.n109.z1.fidonet.org
      via The Black Cat's Shack's FidoNet<->Usenet Gateway
          blkcat.fidonet.org   and   Fidonet 1:109/401

stevec@Apple.COM (Steve Christensen) (01/17/91)

Ken.Knight@f421.n109.z1.fidonet.org (Ken Knight) writes:
>lasky@iris.ucdavis.EDU (Ty Lasky) Asks:
>>1.  If I am using SFGetFile to allow the user to select a file, then I
>>believe I have the name and the volume reference number (or is it the
>>working directory ID?). Now, how do I get the volume name?
> 
>SFGetFile() gives you a volume reference number. What you then need is
>the working directory ID which you can get with a call to GetWDInfo().
>Like this:
>  err = GetWDInfo(0,&(reply.vRefNum),&dirID,&procID);
>  if (err == noErr) {
>     err = HOpen(reply.vRefNum,dirId,reply.fName,permission,refNum);
>     .... /* Permission is the read/write access to want for the file. */
>     .... /* do you thing. */
>  }

Actually SFGetFile() returns a working directory reference number.  To get
the volume reference number, you can either call

	err = GetVRefNum(reply.vRefNum,&volumeRefNum);	[high-level only]

or

	pb.ioNamePtr = nil;
	pb.ioVRefNum = reply.vRefNum;	// working directory refNum
	pb.ioVolIndex = 0;
	err = PBHGetVInfo(&pb,false);
	volumeRefNum = pb.ioVRefNum;	// volume reference number

steve

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Steve Christensen	|  Apple Computer, Inc.		|  Disclaimer:
			|  20525 Mariani Ave, MS-81CS	|   the above may be
  stevec@apple.com	|  Cupertino, CA  95014		|   a lie...or not.

kpmiller@uokmax.ecn.uoknor.edu (Kent P Miller) (03/24/91)

Help!

I am having a problem using the file manager.  I have a complete pathname
to a file, and I need some other information on it (vRefNum, DirID, etc).

When I do a PBHGetFInfo, my machine hangs. (set ioCompleteion = nil, 
ioNamePtr= @completepathname, iovRefName=SFSaveDisk, ioFDirIndex=0, and
I'm not quite sure what to do with IODirId, I tried leaving it alone, and
I tried setting it to 0, neither works)

Does anyone have any ideas or pointers to source code?  Any help would be
much appreciated.

Kent Miller
-- 
-----------------------
Kent Miller
KENT@aardvark.ucs.uoknor.edu
Bitnet -> KENT@uokucsvx