[net.micro.mac] Help on folders

tim@dciem.UUCP (Tim Pointing) (01/08/85)

Help! I am trying to write a disk-backup program which will back up
a MacIntosh disk onto a UNIX-host filesystem. What I am having troubles
with now are folders... There seems to be precious little information
in my copy of Inside Mac about folders. It would seem that the folders
on a disk are actually coming from a resource in the desktop (type 'FOBJ').

My 2 questions are: How do I find out what folders are on a disk?
and
How do I create a new folder? (I want to be able to restore the disk
a close to the way it was as is possible.)
-- 
	Tim Pointing, DCIEM
	{allegra,ubc-vision,linus,ihnp4,uw-beaver,floyd}!utcsrgv!dciem!tim
or	{allegra,ihnp4,linus,decvax}!utzoo!dciem!tim

ech@spuxll.UUCP (Ned Horvath) (01/10/85)

You doped it correctly, folders exist only as "virtual" objects, i.e. as
resources of type FOBJ in the Desktop.  Note that THE Empty Folder has resource
ID -1 -- this fits nicely into Inside Mac's folder ID structure of
	>0	User-defined folders
	0	the disk folder
	-2	the desktop (background)
	-3	trash
Note that you can rename an existing folder 'Empty Folder' (or 'Trash')
without drawing a complaint from the finder: it KNOWS that -1 (-3) is the
'true' Empty Folder (Trash).

A couple of hours of staring at the Desktop with FEdit will reveal a fair
amount of information (I don't have my notes handy) like the folder's name,
the window and location of its icon, and the portRect and coordinate origin
of its window when open.  I haven't yet done the experiment of reading in
FOBJ -1, duplicating it, and adding the resource back to the Desktop with
a new id an name, but I wouldn't bet a lot of money on being able to fool
the Finder that easily (read: I can't account for about half the data in
the FOBJ resource!).

However, all this stuff is NOT documented in Inside Mac, apparently an
intentional omission: the rumor (oft-repeated in these circles of late)
is that Apple is still trying to construct a 'true' hierarchical directory
structure, thus there is a new Finder on the way, and they don't want to
publish the current implementation lest they get committed to it.

What IS documented, and hence what you CAN exploit (he said, with a straight
face), is the fdFldr in each file's finder information (FInfo) -- see the
File Manager doc -- which is indeed the resource ID of the FOBJ for that
folder.  Since any backup of a disk is going to require that you extract and
backup the FInfo anyway, you might as well download and use SetFInfo to
restore it.  You might as well backup/restore the Desktop file too, thereby
capturing all the folders, icons, etc. at one go.  The Desktop is currently
pretty small -- at least, I have gotten burned when mine approached 10kb.

Warning: all of the above is strictly a result of my own observations and
best guesses; in particular, documented or not, I wouldn't trust Apple to
leave the FInfo struct alone, and I sure wouldn't bet on the FOBJ structure
remaining constant.

=Ned=