diff --git a/setter/src/macos/attr.c b/setter/src/macos/attr.c index 0212c45..e9331f4 100644 --- a/setter/src/macos/attr.c +++ b/setter/src/macos/attr.c @@ -63,7 +63,8 @@ void FileAttributes(const char* path) FInfo finderInfo; int32_t count; HFileInfo* fpb; - CInfoPBRec cipbr; + CInfoPBRec cipbr; + HParamBlockRec dirPB; snprintf((char*)str255, 255, "%s", path); hpb.ioNamePtr = str255; @@ -77,13 +78,23 @@ void FileAttributes(const char* path) } refNum = hpb.ioVRefNum; - rc = DirCreate(refNum, fsRtDirID, (unsigned char*)"\pATTRS", &dirId); + memset(&dirPB, 0, sizeof(HParamBlockRec)); + + dirPB.fileParam.ioCompletion = 0; // Nothing, sync + dirPB.fileParam.ioVRefNum = refNum; // Volume specification + dirPB.fileParam.ioNamePtr = (StringPtr) "\pATTRS"; // Directory name to create + dirPB.fileParam.ioDirID = 0; // ID of parent directory, 0 for root of volume + + rc = PBDirCreate(&dirPB, 0); + if(rc) { printf("Error %d creating working directory.\n", rc); return; } + dirId = dirPB.fileParam.ioDirID; + printf("Creating attribute files.\n"); memset(&finderInfo, 0, sizeof(FInfo)); diff --git a/setter/src/macos/deleted.c b/setter/src/macos/deleted.c index 37b8b9a..48c71d7 100644 --- a/setter/src/macos/deleted.c +++ b/setter/src/macos/deleted.c @@ -62,7 +62,8 @@ void DeleteFiles(const char* path) FInfo finderInfo; int32_t count; char filename[9]; - int pos = 0; + int pos = 0; + HParamBlockRec dirPB; snprintf((char*)str255, 255, "%s", path); hpb.ioNamePtr = str255; @@ -76,13 +77,23 @@ void DeleteFiles(const char* path) } refNum = hpb.ioVRefNum; - rc = DirCreate(refNum, fsRtDirID, (unsigned char*)"\pDELETED", &dirId); + memset(&dirPB, 0, sizeof(HParamBlockRec)); + + dirPB.fileParam.ioCompletion = 0; // Nothing, sync + dirPB.fileParam.ioVRefNum = refNum; // Volume specification + dirPB.fileParam.ioNamePtr = (StringPtr) "\pDELETED"; // Directory name to create + dirPB.fileParam.ioDirID = 0; // ID of parent directory, 0 for root of volume + + rc = PBDirCreate(&dirPB, 0); + if(rc) { printf("Error %d creating working directory.\n", rc); return; } + dirId = dirPB.fileParam.ioDirID; + printf("Creating and deleting files.\n"); for(pos = 0; pos < 64; pos++) diff --git a/setter/src/macos/dirdepth.c b/setter/src/macos/dirdepth.c index 2340502..5c00436 100644 --- a/setter/src/macos/dirdepth.c +++ b/setter/src/macos/dirdepth.c @@ -62,7 +62,8 @@ void DirectoryDepth(const char* path) FInfo finderInfo; int32_t count; char filename[9]; - int pos = 0; + int pos = 0; + HParamBlockRec dirPB; snprintf((char*)str255, 255, "%s", path); hpb.ioNamePtr = str255; @@ -76,13 +77,23 @@ void DirectoryDepth(const char* path) } refNum = hpb.ioVRefNum; - rc = DirCreate(refNum, fsRtDirID, (unsigned char*)"\pDEPTH", &dirId); + memset(&dirPB, 0, sizeof(HParamBlockRec)); + + dirPB.fileParam.ioCompletion = 0; // Nothing, sync + dirPB.fileParam.ioVRefNum = refNum; // Volume specification + dirPB.fileParam.ioNamePtr = (StringPtr) "\pDEPTH"; // Directory name to create + dirPB.fileParam.ioDirID = 0; // ID of parent directory, 0 for root of volume + + rc = PBDirCreate(&dirPB, 0); + if(rc) { printf("Error %d creating working directory.\n", rc); return; } + dirId = dirPB.fileParam.ioDirID; + printf("Creating deepest directory tree.\n"); while(!rc) @@ -92,7 +103,16 @@ void DirectoryDepth(const char* path) str255[0] = 8; memcpy(str255 + 1, filename, 8); - rc = DirCreate(refNum, dirId, str255, &dirId); + dirId = dirPB.fileParam.ioDirID; + + memset(&dirPB, 0, sizeof(HParamBlockRec)); + + dirPB.fileParam.ioCompletion = 0; // Nothing, sync + dirPB.fileParam.ioVRefNum = refNum; // Volume specification + dirPB.fileParam.ioNamePtr = str255; // Directory name to create + dirPB.fileParam.ioDirID = dirId; // ID of parent directory, 0 for root of volume + + rc = PBDirCreate(&dirPB, 0); pos++; /* Mac OS has no limit, but it will crash because the catalog is single threaded */ diff --git a/setter/src/macos/filename.c b/setter/src/macos/filename.c index 351c356..d10d2ea 100644 --- a/setter/src/macos/filename.c +++ b/setter/src/macos/filename.c @@ -62,7 +62,8 @@ void Filenames(const char* path) FInfo finderInfo; int32_t count; char message[300]; - int pos = 0; + int pos = 0; + HParamBlockRec dirPB; snprintf((char*)str255, 255, "%s", path); hpb.ioNamePtr = str255; @@ -76,13 +77,23 @@ void Filenames(const char* path) } refNum = hpb.ioVRefNum; - rc = DirCreate(refNum, fsRtDirID, (unsigned char*)"\pFILENAME", &dirId); + memset(&dirPB, 0, sizeof(HParamBlockRec)); + + dirPB.fileParam.ioCompletion = 0; // Nothing, sync + dirPB.fileParam.ioVRefNum = refNum; // Volume specification + dirPB.fileParam.ioNamePtr = (StringPtr) "\pFILENAME"; // Directory name to create + dirPB.fileParam.ioDirID = 0; // ID of parent directory, 0 for root of volume + + rc = PBDirCreate(&dirPB, 0); + if(rc) { printf("Error %d creating working directory.\n", rc); return; } + dirId = dirPB.fileParam.ioDirID; + printf("Creating files with different filenames.\n"); for(pos = 0; filenames[pos]; pos++) diff --git a/setter/src/macos/files.c b/setter/src/macos/files.c index 80cdcc1..c5185fc 100644 --- a/setter/src/macos/files.c +++ b/setter/src/macos/files.c @@ -62,7 +62,8 @@ void MillionFiles(const char* path) FInfo finderInfo; int32_t count; char filename[9]; - int pos = 0; + int pos = 0; + HParamBlockRec dirPB; snprintf((char*)str255, 255, "%s", path); hpb.ioNamePtr = str255; @@ -76,7 +77,17 @@ void MillionFiles(const char* path) } refNum = hpb.ioVRefNum; - rc = DirCreate(refNum, fsRtDirID, (unsigned char*)"\pMILLION", &dirId); + memset(&dirPB, 0, sizeof(HParamBlockRec)); + + dirPB.fileParam.ioCompletion = 0; // Nothing, sync + dirPB.fileParam.ioVRefNum = refNum; // Volume specification + dirPB.fileParam.ioNamePtr = (StringPtr) "\pMILLION"; // Directory name to create + dirPB.fileParam.ioDirID = 0; // ID of parent directory, 0 for root of volume + + rc = PBDirCreate(&dirPB, 0); + + dirId = dirPB.fileParam.ioDirID; + if(rc) { printf("Error %d creating working directory.\n", rc); diff --git a/setter/src/macos/frag.c b/setter/src/macos/frag.c index 3f0f592..922ac8d 100644 --- a/setter/src/macos/frag.c +++ b/setter/src/macos/frag.c @@ -67,6 +67,7 @@ void Fragmentation(const char* path, size_t clusterSize) int32_t dirId; int32_t count; long i; + HParamBlockRec dirPB; snprintf((char*)str255, 255, "%s", path); hpb.ioNamePtr = str255; @@ -80,7 +81,17 @@ void Fragmentation(const char* path, size_t clusterSize) } refNum = hpb.ioVRefNum; - rc = DirCreate(refNum, fsRtDirID, (unsigned char*)"\pFRAGS", &dirId); + memset(&dirPB, 0, sizeof(HParamBlockRec)); + + dirPB.fileParam.ioCompletion = 0; // Nothing, sync + dirPB.fileParam.ioVRefNum = refNum; // Volume specification + dirPB.fileParam.ioNamePtr = (StringPtr) "\pFRAGS"; // Directory name to create + dirPB.fileParam.ioDirID = 0; // ID of parent directory, 0 for root of volume + + rc = PBDirCreate(&dirPB, 0); + + dirId = dirPB.fileParam.ioDirID; + if(rc) { printf("Error %d creating working directory.\n", rc); diff --git a/setter/src/macos/links.c b/setter/src/macos/links.c index a099607..d5dfa20 100644 --- a/setter/src/macos/links.c +++ b/setter/src/macos/links.c @@ -99,7 +99,8 @@ void Links(const char* path) char filename[9]; int pos = 0; FSSpec targetSpec, aliasSpec; - int32_t count; + int32_t count; + HParamBlockRec dirPB; rc = Gestalt(gestaltAliasMgrAttr, &gestaltResponse); if(rc || !(gestaltResponse & (1 << gestaltAliasMgrPresent))) @@ -120,13 +121,23 @@ void Links(const char* path) } refNum = hpb.ioVRefNum; - rc = DirCreate(refNum, fsRtDirID, (unsigned char*)"\pLINKS", &dirId); + memset(&dirPB, 0, sizeof(HParamBlockRec)); + + dirPB.fileParam.ioCompletion = 0; // Nothing, sync + dirPB.fileParam.ioVRefNum = refNum; // Volume specification + dirPB.fileParam.ioNamePtr = (StringPtr) "\pLINKS"; // Directory name to create + dirPB.fileParam.ioDirID = 0; // ID of parent directory, 0 for root of volume + + rc = PBDirCreate(&dirPB, 0); + if(rc) { printf("Error %d creating working directory.\n", rc); return; } + dirId = dirPB.fileParam.ioDirID; + printf("Creating aliases.\n"); for(pos = 0; pos < 64; pos++) diff --git a/setter/src/macos/retro68.h b/setter/src/macos/retro68.h index 87de077..63305d3 100644 --- a/setter/src/macos/retro68.h +++ b/setter/src/macos/retro68.h @@ -12,6 +12,7 @@ enum }; #define PBHGetVInfo(pb, async) ((async) ? PBHGetVInfoAsync(pb) : PBHGetVInfoSync(pb)) +#define PBDirCreate(pb, async) ((async) ? PBDirCreateAsync(pb) : PBDirCreateSync(pb)) #define FOUR_CHAR_CODE(x) (x) diff --git a/setter/src/macos/rsrcfork.c b/setter/src/macos/rsrcfork.c index 8d7a9f9..3851758 100644 --- a/setter/src/macos/rsrcfork.c +++ b/setter/src/macos/rsrcfork.c @@ -101,7 +101,8 @@ void ResourceFork(const char* path) FInfo finderInfo; int32_t count; HFileInfo* fpb; - CInfoPBRec cipbr; + CInfoPBRec cipbr; + HParamBlockRec dirPB; snprintf((char*)str255, 255, "%s", path); hpb.ioNamePtr = str255; @@ -115,13 +116,23 @@ void ResourceFork(const char* path) } refNum = hpb.ioVRefNum; - rc = DirCreate(refNum, fsRtDirID, (unsigned char*)"\pRSRC", &dirId); + memset(&dirPB, 0, sizeof(HParamBlockRec)); + + dirPB.fileParam.ioCompletion = 0; // Nothing, sync + dirPB.fileParam.ioVRefNum = refNum; // Volume specification + dirPB.fileParam.ioNamePtr = (StringPtr) "\pRSRC"; // Directory name to create + dirPB.fileParam.ioDirID = 0; // ID of parent directory, 0 for root of volume + + rc = PBDirCreate(&dirPB, 0); + if(rc) { printf("Error %d creating working directory.\n", rc); return; } + dirId = dirPB.fileParam.ioDirID; + printf("Creating resource forks.\n"); memset(&finderInfo, 0, sizeof(FInfo)); diff --git a/setter/src/macos/time.c b/setter/src/macos/time.c index f5653e6..d21c023 100644 --- a/setter/src/macos/time.c +++ b/setter/src/macos/time.c @@ -64,7 +64,8 @@ void Timestamps(const char* path) int32_t count; HFileInfo* fpb; CInfoPBRec cipbr; - char message[300]; + char message[300]; + HParamBlockRec dirPB; snprintf((char*)str255, 255, "%s", path); hpb.ioNamePtr = str255; @@ -78,13 +79,23 @@ void Timestamps(const char* path) } refNum = hpb.ioVRefNum; - rc = DirCreate(refNum, fsRtDirID, (unsigned char*)"\pTIMES", &dirId); + memset(&dirPB, 0, sizeof(HParamBlockRec)); + + dirPB.fileParam.ioCompletion = 0; // Nothing, sync + dirPB.fileParam.ioVRefNum = refNum; // Volume specification + dirPB.fileParam.ioNamePtr = (StringPtr) "\pTIMES"; // Directory name to create + dirPB.fileParam.ioDirID = 0; // ID of parent directory, 0 for root of volume + + rc = PBDirCreate(&dirPB, 0); + if(rc) { printf("Error %d creating working directory.\n", rc); return; } + dirId = dirPB.fileParam.ioDirID; + printf("Creating timestamped files.\n"); rc = HCreate(refNum, dirId, "\pMAXCTIME", ostUnknown, ftGenericDocumentPC);