home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!munnari.oz.au!uniwa!cujo!ncrpda.curtin.edu.au!rocky.curtin.edu.au!user
- From: peter@cujo.curtin.edu.au (Peter N Lewis)
- Subject: Re: Getting List of files contained in folder
- Message-ID: <peter-120193114153@rocky.curtin.edu.au>
- Followup-To: comp.sys.mac.programmer
- Lines: 133
- Sender: news@ncrpda.curtin.edu.au
- Nntp-Posting-Host: ncrpda.curtin.edu.au
- Organization: NCRPDA, Curtin University
- References: <1993Jan11.113821.12019@wega.rz.uni-ulm.de>
- Date: Tue, 12 Jan 1993 03:46:37 GMT
-
- In article <1993Jan11.113821.12019@wega.rz.uni-ulm.de>,
- walrath@faw.uni-ulm.de (Wayne K. Walrath) wrote:
- >
- > I have been reading through the New IM-Files trying to figure this one
- > out: if I have a folder specification (like when I have thrown up a
- > dialog for the user to choose one) how can I get a list of all the files
- > and folders contained in the folder?
-
- Here's a program I wrote to list out all the THINK Pascal projects that are
- over 50k (so I could go thru and manually remove objects on all of them,
- which got me 5Meg of disk space back! I wish Symantec would get around to
- releasing their utility for doing this, my old one doesn't work for
- v4.0.2)-:
-
- It does a recursive scan give an volume reference number & dirID.
-
- As Jon said, learn to love the PBGetCatInfo call, its very important (less
- important than learning the difference between vrn's and working directory
- numbers and how dirIDs fit in, but still quite important).
-
- program Scan;
-
- uses
- MyUtilities, MyStandardFile;
-
- var
- path: str255;
-
- procedure Doit (vrn: integer; dirID: longInt; fname: str63);
- var
- pb: HParamBlockRec;
- oe: OSErr;
- rn: integer;
- begin
- with pb do begin
- ioNamePtr := @fname;
- ioVRefNum := vrn;
- ioDirID := dirID;
- ioFDirIndex := 0;
- oe := PBGetCatInfo(@pb, false);
- end;
- if (oe = noErr) & (pb.ioFlFndrInfo.fdType = 'QPRJ') & (pb.ioFlRLgLen >
- 50000) then begin
- writeln(concat(path, ':', fname));
- end;
- end;
-
- procedure WaitForEvent (sleep: integer);
- var
- er: EventRecord;
- dummy: boolean;
- begin
- dummy := WaitNextEvent(everyEvent, er, sleep, nil);
- end;
-
- procedure ScanFolders (vrn: integer; dirID: longInt);
- var
- pb: HParamBlockRec;
- name: str63;
- procedure Scan (dirID: longInt);
- var
- index, len: integer;
- oe: OSErr;
- begin
- WaitForEvent(5);
- index := 1;
- repeat
- with pb do begin
- ioNamePtr := @name;
- ioVRefNum := vrn;
- ioDirID := dirID;
- ioFDirIndex := index;
- oe := PBGetCatInfo(@pb, false);
- if oe = noErr then
- if BAND(pb.ioFlAttrib, $10) = 0 then
- Doit(vrn, dirID, name)
- else begin
- len := length(path);
- path := concat(path, ':', name);
- Scan(pb.ioDirID);
- path[0] := chr(len);
- end;
- index := index + 1;
- end;
- until oe <> noErr;
- WaitForEvent(5);
- end;
- begin
- Scan(dirID);
- end;
-
- var
- reply: MySFReply;
- typeList: SFTypeList;
- begin
- path := '';
- ShowText;
- InitUtilities;
- {GetFolder(nil, -1, typeList, 500, reply);}
- reply.Rgood := true;
- reply.RvRefNum := -1;
- reply.RdirID := 2;
- reply.Rfolder := true;
- with reply do
- if Rgood then begin
- if Rfolder then
- ScanFolders(RvRefNum, RDirID)
- else
- Doit(RvRefNum, RDirID, RfName);
- end;
- write('Finished - Click the Mouse Button');
- while not Button do
- WaitForEvent(15);
- end.
-
- > Is it possible to use the new Cat Search function
- > available under 7.x (_FSBCatSearch or something similiar) but limit it to
- > only the folder in question?
-
- Beats me.
-
- > I would appreciate a general explanation of how to do this, or better
- > still some code.
-
- There is the code, all it does is use the ioFDirIndex field to call
- PBGetCatInfo successively with a larger index til it runs off the end of
- the folder...
-
- Have fun,
- Peter.
-
- _______________________________________________________________________
- Peter N Lewis <peter@cujo.curtin.edu.au> Ph: +61 9 368 2055
-