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.