[comp.sys.mac.programmer] LSC File Manager questions

moyman@ecn.purdue.edu (James M Moya) (04/11/90)

Two questions:

[1] I am trying to find the easiest way to get the VRefNum given only the
the Name of the volume (Str255)...I read Inside mac about 60 times and it
hasn't sunk in yet.  I made up a horrible loop using GetVInfo
and got sick, but it worke...There must be a better way...

[2] I wrote a recursive routine that copies everything from one
volume to another.  It works fine in that everything is copied.  The
part I have not been able to figure out is the folder window size and
the position of the files inside folders...They are all messed up after the 
copy.  I want it to be just like a finder copy in that everything is 
preserved it the same position, etc...Anybody know what attribute I am 
forgetting to copy over (I am copying the ioFlFndrInfo field)??  Or is that 
the problem...I am re-reading Inside Mac for the 61st time to try and  
figure this out...Please e-mail me if you have any suggestions...


Mike Moya
Engineering Computer Network
Purdue University

tim@hoptoad.uucp (Tim Maroney) (04/13/90)

In article <1990Apr11.135700.28759@ecn.purdue.edu> moyman@ecn.purdue.edu
(James M Moya) writes:
>[1] I am trying to find the easiest way to get the VRefNum given only the
>the Name of the volume (Str255)...I read Inside mac about 60 times and it
>hasn't sunk in yet.  I made up a horrible loop using GetVInfo
>and got sick, but it worke...There must be a better way...

Use the low-level PBGetVInfo trap, with ioVolIndex negative, ioVRefNum
zero, and ioNamePtr set to the name of the volume.  IM IV-129.  Or use
PBHGetVInfo the same way for more information.

>[2] I wrote a recursive routine that copies everything from one
>volume to another.  It works fine in that everything is copied.  The
>part I have not been able to figure out is the folder window size and
>the position of the files inside folders...They are all messed up after the 
>copy.  I want it to be just like a finder copy in that everything is 
>preserved it the same position, etc...Anybody know what attribute I am 
>forgetting to copy over (I am copying the ioFlFndrInfo field)?

That's odd -- usually, a naive copy of the finder information *does*
preserve the file's folder location, which is rarely what you want.
Generally, most file copies want to zero the inited bit, which is bit 9
or 10 of the fdFlags word.  (I can never remember which, and it isn't
documented.)  If you don't zero this bit, then the Finder will use
whatever location is stored in fdLocation, without trying to find a
sane location for the file.

Keeping the old file location will look funny if the view for the new
folder isn't the same as for the old folder.  Notice that the location
and view of a folder are stored in the DInfo structure which is found
in the ioDrUsrWds of the CInfoPBRec used by PBGetCatInfo/PBSetCatInfo.
You should be sure to copy the ioDrUsrWds and ioDrFndrinfo from the old
folder to the new folder when you copy.

But as for the file locations, all I can say is, when I copy an
unmodified ioFlFndrInfo from an old file to a new file, it *does*
preserve the file position in its folder window.  Maybe you aren't
actually copying part of the finder information structure?  Or maybe
it's a side efefct of not copying the folder's own finder info?
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"Every institution I've ever been associated with has tried to screw me."
	-- Stephen Wolfram