HyperCard: HFSCopy External


Article Change History
---------------------
09/01/92 - REVIEWED
* For technical accuracy


I am developing a HyperCard front end for software distribution via AppleShare
servers and using the HFSCopy XFCN to copy files from servers to users' hard
drives. I have also made stacks that do validation and audit trails
(including MS Mail API) and log the user onto the server, based on certain
access privileges. After logging on the user has to drag down the folders
from the server manually. This may have to be the solution if the stack can
automate the "copy."

HFSCopy works great the first time, but the next time it is executed, it won't
work with a duplicate folder name on the user's hard disk. Is there a
simple solution to this? Or do I have to verify the user's folders every time
and/or rename the existing folder to "<folder name> old" or something like
that?

How can I use HFSCopy without knowing the name of the destination hard drive? I
don't want to require users to enter the name of their hard drive or the script

to search for the volume name. A wildcard does not seem to work. I would
like HyperCard to do the HFS Copy to the HyperCard launch volume. HyperCard
knows where it is being launched from, so I need to tell the script this
information. How can I access this information?

You're right: the HFSCopy XFCN does not replace a folder with the same name.
It does, however, return an error that you can check, as a way to work around
this. Error -48 indicates a duplicate filename. You could write a script that
uses a few XFCNs to index through the folder that you want to replace, deleting
each of the files in the folder until the folder is empty, and then deleting
the folder. Once this is done, you could then call the HFSCopy XFCN again,
asking for the original folder. Because the folder no longer exists on your
local disk, it will be copied successfully.

There are two XFCNs beyond HFSCopy that would help: FolderContents and
DeleteFile.

The FolderContents XFCN returns the files and/or folders contained in a
specified folder. Its syntax is:

FolderContents(Pathname, Ã,"Files"|"Folders"|"Both"╚ Ã"noDialog:"errorGlobal╚)

where Pathname is a path to a folder to examine and parameter 2 is the literal
string "Files", "Folders", or "Both".

This XFCN returns a carriage return delimited list (one file/folder per line)
of all files, folders, or both files and folders (as per parameter 2) within
the specified directory. The names of all folders will end in ":". The
default is to list "both" files and folders. (The next version will be A/UX
compatible.)

The third XFCN is DeleteFile, which deletes the file you specify. Specify the
full pathname, as with the other two XFCNs. To delete a folder, that folder
must be empty and you must trick the XCFN into thinking that the folder is a
file. Therefore, delete everything in the folder, then call this XCFN once more
using the folder name as a file name. In other words, where you would usually
specify a folder name like "Hard Disk:folder1:", in this case, you omit
the last colon and pass the parameter "Hard Disk:folder1". Thus, DeleteFile
will think the folder is a file, and--as long as the folder is empty--will
delete it. Remember that if there are folders within folders you must work
your way from the deepest folder out, deleting files and folders as you go.

To get HyperCard's full pathname, use the HyperCard command "the long name of
stack home". From the result, you can derive the information you need.



Published Date: Feb 18, 2012