From 6dd972c78194e4b0d68d9f7a6febd279463cae9b Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 16 Mar 2021 05:38:17 +0000 Subject: [PATCH] Fix text when creating resource forks in MacOS. --- setter/src/macos/rsrcfork.c | 29 +++++++++++++++-------------- setter/src/macos/rsrcfork.h | 3 +++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/setter/src/macos/rsrcfork.c b/setter/src/macos/rsrcfork.c index 3de819d..bc72df5 100644 --- a/setter/src/macos/rsrcfork.c +++ b/setter/src/macos/rsrcfork.c @@ -121,28 +121,28 @@ void ResourceFork(const char* path) log_write("Creating resource forks.\n"); memset(&finderInfo, 0, sizeof(FInfo)); - rc = HCreate(refNum, dirId, "\pICON", ostUnknown, ftGenericDocumentPC); + rc = HCreate(refNum, dirId, "\pICNS", ostUnknown, ftGenericDocumentPC); if(!rc) { rRc = SaveResourceToNewFile(refNum, dirId, - "\pICON", + "\pICNS", rtIcons, -16455, "\pIcon resource", (unsigned char*)IcnsResource, sizeof(IcnsResource)); - rc = HOpenDF(refNum, dirId, "\pICON", 0, &refFile); + rc = HOpenDF(refNum, dirId, "\pICNS", 0, &refFile); if(!rc) { memset(&fpb, 0, sizeof(HParamBlockRec)); - count = strlen(rsrcText); - wRc = FSWrite(refFile, &count, rsrcText); + count = strlen(icnsText); + wRc = FSWrite(refFile, &count, icnsText); cRc = FSClose(refFile); fpb.fileParam.ioVRefNum = refNum; - fpb.fileParam.ioNamePtr = "\pICON"; + fpb.fileParam.ioNamePtr = "\pICNS"; fpb.fileParam.ioDirID = dirId; fpb.fileParam.ioFlFndrInfo.fdType = ftGenericDocumentPC; fpb.fileParam.ioFlFndrInfo.fdCreator = ostAaru; @@ -151,8 +151,8 @@ void ResourceFork(const char* path) rc = PBHSetFInfoSync(&fpb); } } - log_write("\tFile with three items in the resource fork: name = \"%s\", rc = %d, wRc = %d, cRc = %d, rRc = %d\n", - "ICON", + log_write("\tFile with an icon in the resource fork: name = \"%s\", rc = %d, wRc = %d, cRc = %d, rRc = %d\n", + "ICNS", rc, wRc, cRc, @@ -175,8 +175,8 @@ void ResourceFork(const char* path) { memset(&fpb, 0, sizeof(HParamBlockRec)); - count = strlen(rsrcText); - wRc = FSWrite(refFile, &count, rsrcText); + count = strlen(pictText); + wRc = FSWrite(refFile, &count, pictText); cRc = FSClose(refFile); finderInfo.fdType = ftPICTFile; finderInfo.fdCreator = ostAaru; @@ -190,7 +190,7 @@ void ResourceFork(const char* path) rc = PBHSetFInfoSync(&fpb); } } - log_write("\tFile with three items in the resource fork: name = \"%s\", rc = %d, wRc = %d, cRc = %d, rRc = %d\n", + log_write("\tFile with a picture in the resource fork: name = \"%s\", rc = %d, wRc = %d, cRc = %d, rRc = %d\n", "PICT", rc, wRc, @@ -214,8 +214,8 @@ void ResourceFork(const char* path) { memset(&fpb, 0, sizeof(HParamBlockRec)); - count = strlen(rsrcText); - wRc = FSWrite(refFile, &count, rsrcText); + count = strlen(versText); + wRc = FSWrite(refFile, &count, versText); cRc = FSClose(refFile); fpb.fileParam.ioVRefNum = refNum; @@ -227,7 +227,8 @@ void ResourceFork(const char* path) rc = PBHSetFInfoSync(&fpb); } } - log_write("\tFile with three items in the resource fork: name = \"%s\", rc = %d, wRc = %d, cRc = %d, rRc = %d\n", + log_write("\tFile with an icon, a picture and a version in the resource fork: name = \"%s\", rc = %d, wRc = %d, " + "cRc = %d, rRc = %d\n", "VERSION", rc, wRc, diff --git a/setter/src/macos/rsrcfork.h b/setter/src/macos/rsrcfork.h index 46f0d89..4a26aef 100644 --- a/setter/src/macos/rsrcfork.h +++ b/setter/src/macos/rsrcfork.h @@ -34,6 +34,9 @@ static OSErr SaveResourceToNewFile(int16_t vRefNum, unsigned char* buffer, size_t length); +const char* icnsText = "This file has a custom icon in the resource fork.\r"; +const char* versText = "This file has a version in the resource fork.\r"; +const char* pictText = "This file has a picture, in the resource fork.\r"; const char* rsrcText = "This file has a custom icon, a version, and a picture, in the resource fork.\r"; const unsigned char IcnsResource[5618] = {