===================================================================
@@ -166,46 +166,46 @@ copyfork(HFSUniStr255 *forkName, FSRef *
#define min(x, y) ((x) < y) ? (x) : (y)
-filecopy(char *src, char *dst, UInt64 maxbufsize, int preserve){
- FSCatalogInfo srcCat, dstCat;
- if (err = FSPathMakeRef(src, &srcFS, NULL))
- if (err = FSGetCatalogInfo(&srcFS, kFSCatInfoGettableInfo, &srcCat,
- bcopy(&srcCat, &dstCat, sizeof(FSCatalogInfo));
- if (err = newfile(dst, &dstFS, &dstCat)){
- fpf(stderr, "Cannot Create File %s\n", dst);
- if (srcCat.dataLogicalSize){
- setbufsiz(min(srcCat.dataPhysicalSize, maxbufsize));
- FSGetDataForkName(&forkName);
- if (err = copyfork(&forkName, &srcFS, &dstFS))
- if (srcCat.rsrcLogicalSize){
- setbufsiz(min(srcCat.rsrcPhysicalSize, maxbufsize));
- FSGetResourceForkName(&forkName);
- if (err = copyfork(&forkName, &srcFS, &dstFS))
- err = FSSetCatalogInfo(&dstFS, kFSCatInfoSettableInfo, &srcCat);
+filecopy(char *src, char *dst, UInt64 maxbufsize, int preserve)
+ char *lastSlash = NULL;
+ char *tmpString = NULL;
+ if (NULL == dst || NULL == src) {
+ /* split the dst into the dir and the filename */
+ if (NULL == (tmpString = dirname(dst))) {
+ /* dirname() failed... */
+ return errno + kPOSIXErrorBase;
+ destDir = calloc((strlen(tmpString) + 2), sizeof(char));
+ /* failed to allocate mem */
+ return errno + kPOSIXErrorBase;
+ if (strlcpy(destDir, tmpString, (strlen(tmpString) + 1)) > (strlen(tmpString))) {
+ return kPOSIXErrorERANGE;
+ if (NULL == (tmpString = basename(dst))) {
+ /* basename() failed... */
+ return errno + kPOSIXErrorBase;
+ destFname = CFStringCreateWithCString(kCFAllocatorDefault, tmpString, kCFStringEncodingMacRoman);
+ status = FSPathCopyObjectSync(src, destDir, destFname, NULL, kFSFileOperationSkipPreflight);
+ // fprintf(stderr, "FSPathCOpyObjectSync(%s, %s, %s,...) status is \"%d\"\n", (NULL != src ? src : "<NULL>"), (NULL != destDir ? destDir: "<NULL>"), (NULL != tmpString ? tmpString: "<NULL>"), status);
filemove(char *src, char *dst){
===================================================================