From c47a41cecc9c49aeff495af11083cdd805c93a00 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 14 Mar 2021 06:44:56 +0000 Subject: [PATCH] Replace calls to HSetFInfo() with PBHSetFInfoSync(). --- setter/src/macos/attr.c | 30 +++++++++------ setter/src/macos/rsrcfork.c | 76 ++++++++++++++++++++++++++----------- 2 files changed, 72 insertions(+), 34 deletions(-) diff --git a/setter/src/macos/attr.c b/setter/src/macos/attr.c index b742eec..c053387 100644 --- a/setter/src/macos/attr.c +++ b/setter/src/macos/attr.c @@ -61,8 +61,8 @@ void FileAttributes(const char* path) int16_t refFile; int32_t dirId; FInfo finderInfo; - int32_t count; - HFileInfo* fpb; + int32_t count; + HParamBlockRec fpb; CInfoPBRec cipbr; HParamBlockRec dirPB; int i; @@ -112,15 +112,23 @@ void FileAttributes(const char* path) if(!rc) { - count = strlen(mac_attrs[i].contents); - wRc = FSWrite(refFile, &count, mac_attrs[i].contents); - cRc = FSClose(refFile); - finderInfo.fdType = mac_attrs[i].type; - finderInfo.fdCreator = mac_attrs[i].creator; - finderInfo.fdFlags = mac_attrs[i].flags; - finderInfo.fdLocation.h = mac_attrs[i].location.h; - finderInfo.fdLocation.v = mac_attrs[i].location.v; - rc = HSetFInfo(refNum, dirId, mac_attrs[i].filename, &finderInfo); + memset(&fpb, 0, sizeof(HParamBlockRec)); + + count = strlen(mac_attrs[i].contents); + wRc = FSWrite(refFile, &count, mac_attrs[i].contents); + cRc = FSClose(refFile); + + fpb.fileParam.ioVRefNum = refNum; + fpb.fileParam.ioNamePtr = str255; + fpb.fileParam.ioDirID = dirId; + fpb.fileParam.ioFDirIndex = 0; + fpb.fileParam.ioFlFndrInfo.fdType = mac_attrs[i].type; + fpb.fileParam.ioFlFndrInfo.fdCreator = mac_attrs[i].creator; + fpb.fileParam.ioFlFndrInfo.fdFlags = mac_attrs[i].flags; + fpb.fileParam.ioFlFndrInfo.fdLocation.h = mac_attrs[i].location.h; + fpb.fileParam.ioFlFndrInfo.fdLocation.v = mac_attrs[i].location.v; + + rc = PBHSetFInfoSync(&fpb); } } diff --git a/setter/src/macos/rsrcfork.c b/setter/src/macos/rsrcfork.c index eb6b2de..d211029 100644 --- a/setter/src/macos/rsrcfork.c +++ b/setter/src/macos/rsrcfork.c @@ -99,8 +99,8 @@ void ResourceFork(const char* path) int16_t refFile; int32_t dirId; FInfo finderInfo; - int32_t count; - HFileInfo* fpb; + int32_t count; + HParamBlockRec fpb; CInfoPBRec cipbr; HParamBlockRec dirPB; @@ -150,13 +150,20 @@ void ResourceFork(const char* path) rc = HOpenDF(refNum, dirId, "\pICON", 0, &refFile); if(!rc) { - count = strlen(rsrcText); - wRc = FSWrite(refFile, &count, rsrcText); - cRc = FSClose(refFile); - finderInfo.fdType = ftGenericDocumentPC; - finderInfo.fdCreator = ostAaru; - finderInfo.fdFlags = kHasCustomIcon; - rc = HSetFInfo(refNum, dirId, "\pICON", &finderInfo); + memset(&fpb, 0, sizeof(HParamBlockRec)); + + count = strlen(rsrcText); + wRc = FSWrite(refFile, &count, rsrcText); + cRc = FSClose(refFile); + + fpb.fileParam.ioVRefNum = refNum; + fpb.fileParam.ioNamePtr = "\pICON"; + fpb.fileParam.ioDirID = dirId; + fpb.fileParam.ioFlFndrInfo.fdType = ftGenericDocumentPC; + fpb.fileParam.ioFlFndrInfo.fdCreator = ostAaru; + fpb.fileParam.ioFlFndrInfo.fdFlags = kHasCustomIcon; + + rc = PBHSetFInfoSync(&fpb); } } printf("\tFile with three items in the resource fork: name = \"%s\", rc = %d, wRc = %d, cRc = %d, rRc = %d\n", @@ -181,12 +188,21 @@ void ResourceFork(const char* path) rc = HOpenDF(refNum, dirId, "\pPICT", 0, &refFile); if(!rc) { + memset(&fpb, 0, sizeof(HParamBlockRec)); + count = strlen(rsrcText); wRc = FSWrite(refFile, &count, rsrcText); cRc = FSClose(refFile); finderInfo.fdType = ftPICTFile; finderInfo.fdCreator = ostAaru; - rc = HSetFInfo(refNum, dirId, "\pPICT", &finderInfo); + + fpb.fileParam.ioVRefNum = refNum; + fpb.fileParam.ioNamePtr = "\pPICT"; + fpb.fileParam.ioDirID = dirId; + fpb.fileParam.ioFlFndrInfo.fdType = ftPICTFile; + fpb.fileParam.ioFlFndrInfo.fdCreator = ostAaru; + + rc = PBHSetFInfoSync(&fpb); } } printf("\tFile with three items in the resource fork: name = \"%s\", rc = %d, wRc = %d, cRc = %d, rRc = %d\n", @@ -211,12 +227,19 @@ void ResourceFork(const char* path) rc = HOpenDF(refNum, dirId, "\pVERSION", 0, &refFile); if(!rc) { - count = strlen(rsrcText); - wRc = FSWrite(refFile, &count, rsrcText); - cRc = FSClose(refFile); - finderInfo.fdType = ftGenericDocumentPC; - finderInfo.fdCreator = ostAaru; - rc = HSetFInfo(refNum, dirId, "\pVERSION", &finderInfo); + memset(&fpb, 0, sizeof(HParamBlockRec)); + + count = strlen(rsrcText); + wRc = FSWrite(refFile, &count, rsrcText); + cRc = FSClose(refFile); + + fpb.fileParam.ioVRefNum = refNum; + fpb.fileParam.ioNamePtr = "\pVERSION"; + fpb.fileParam.ioDirID = dirId; + fpb.fileParam.ioFlFndrInfo.fdType = ftGenericDocumentPC; + fpb.fileParam.ioFlFndrInfo.fdCreator = ostAaru; + + rc = PBHSetFInfoSync(&fpb); } } printf("\tFile with three items in the resource fork: name = \"%s\", rc = %d, wRc = %d, cRc = %d, rRc = %d\n", @@ -257,13 +280,20 @@ void ResourceFork(const char* path) rc = HOpenDF(refNum, dirId, "\pALL", 0, &refFile); if(!rc) { - count = strlen(rsrcText); - wRc = FSWrite(refFile, &count, rsrcText); - cRc = FSClose(refFile); - finderInfo.fdType = ftPICTFile; - finderInfo.fdCreator = ostAaru; - finderInfo.fdFlags = kHasCustomIcon; - rc = HSetFInfo(refNum, dirId, "\pALL", &finderInfo); + memset(&fpb, 0, sizeof(HParamBlockRec)); + + count = strlen(rsrcText); + wRc = FSWrite(refFile, &count, rsrcText); + cRc = FSClose(refFile); + + fpb.fileParam.ioVRefNum = refNum; + fpb.fileParam.ioNamePtr = "\pALL"; + fpb.fileParam.ioDirID = dirId; + fpb.fileParam.ioFlFndrInfo.fdType = ftPICTFile; + fpb.fileParam.ioFlFndrInfo.fdCreator = ostAaru; + fpb.fileParam.ioFlFndrInfo.fdFlags = kHasCustomIcon; + + rc = PBHSetFInfoSync(&fpb); } } printf("\tFile with three items in the resource fork: name = \"%s\", rc = %d, wRc = %d, cRc = %d, rRc = %d, rRc2 = "