mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Set MacOS attributes using a for loop instead of repeating code.
This commit is contained in:
@@ -65,6 +65,7 @@ void FileAttributes(const char* path)
|
||||
HFileInfo* fpb;
|
||||
CInfoPBRec cipbr;
|
||||
HParamBlockRec dirPB;
|
||||
int i;
|
||||
|
||||
snprintf((char*)str255, 255, "%s", path);
|
||||
hpb.ioNamePtr = str255;
|
||||
@@ -97,611 +98,38 @@ void FileAttributes(const char* path)
|
||||
|
||||
printf("Creating attribute files.\n");
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pNONE", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
for(i = 0; i < KNOWN_MAC_ATTRS; i++)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pNONE", 0, &refFile);
|
||||
memset(str255, 0, 256);
|
||||
memcpy(str255, mac_attrs[i].filename, strlen(mac_attrs[i].filename));
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, str255, ostUnknown, ftGenericDocumentPC);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(noAttributeText);
|
||||
wRc = FSWrite(refFile, &count, noAttributeText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
rc = HSetFInfo(refNum, dirId, "\pNONE", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with no attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "NONE", rc, wRc, cRc);
|
||||
rc = HOpenDF(refNum, dirId, str255, 0, &refFile);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pINDESK", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pINDESK", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(desktopText);
|
||||
wRc = FSWrite(refFile, &count, desktopText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kIsOnDesk;
|
||||
rc = HSetFInfo(refNum, dirId, "\pINDESK", &finderInfo);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\tFile is in desktop: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "INDESK", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pBROWN", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pBROWN", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(color2Text);
|
||||
wRc = FSWrite(refFile, &count, color2Text);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = 0x02;
|
||||
rc = HSetFInfo(refNum, dirId, "\pBROWN", &finderInfo);
|
||||
}
|
||||
printf("\t%s: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
mac_attrs[i].description,
|
||||
mac_attrs[i].filename,
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
}
|
||||
printf("\tFile is colored brown: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "BROWN", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pGREEN", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pGREEN", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(color4Text);
|
||||
wRc = FSWrite(refFile, &count, color4Text);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = 0x04;
|
||||
rc = HSetFInfo(refNum, dirId, "\pGREEN", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is colored green: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "GREEN", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pLILAC", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pLILAC", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(color6Text);
|
||||
wRc = FSWrite(refFile, &count, color6Text);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = 0x06;
|
||||
rc = HSetFInfo(refNum, dirId, "\pLILAC", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is colored lilac: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "LILAC", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pBLUE", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pBLUE", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(color8Text);
|
||||
wRc = FSWrite(refFile, &count, color8Text);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = 0x08;
|
||||
rc = HSetFInfo(refNum, dirId, "\pBLUE", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is colored blue: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "BLUE", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pMAGENTA", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pMAGENTA", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(colorAText);
|
||||
wRc = FSWrite(refFile, &count, colorAText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = 0x0A;
|
||||
rc = HSetFInfo(refNum, dirId, "\pMAGENTA", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is colored magenta: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "MAGENTA", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pRED", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pRED", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(colorCText);
|
||||
wRc = FSWrite(refFile, &count, colorCText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = 0x0C;
|
||||
rc = HSetFInfo(refNum, dirId, "\pRED", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is colored red: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "RED", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pORANGE", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pORANGE", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(colorEText);
|
||||
wRc = FSWrite(refFile, &count, colorEText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = 0x0E;
|
||||
rc = HSetFInfo(refNum, dirId, "\pORANGE", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is colored orange: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "ORANGE", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pSWITCH", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pSWITCH", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(requireSwitchText);
|
||||
wRc = FSWrite(refFile, &count, requireSwitchText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kRequireSwitchLaunch;
|
||||
rc = HSetFInfo(refNum, dirId, "\pSWITCH", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile require switch launch: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "SWITCH", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pSHARED", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pSHARED", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(sharedText);
|
||||
wRc = FSWrite(refFile, &count, sharedText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kIsShared;
|
||||
rc = HSetFInfo(refNum, dirId, "\pSHARED", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is shared: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "SHARED", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pNOINIT", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pNOINIT", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(noInitText);
|
||||
wRc = FSWrite(refFile, &count, noInitText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kHasNoINITs;
|
||||
rc = HSetFInfo(refNum, dirId, "\pNOINIT", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile has no INITs: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "NOINIT", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pINITED", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pINITED", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(initedText);
|
||||
wRc = FSWrite(refFile, &count, initedText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kHasBeenInited;
|
||||
rc = HSetFInfo(refNum, dirId, "\pINITED", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile has been INITed: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "INITED", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pAOCE", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pAOCE", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(aoceText);
|
||||
wRc = FSWrite(refFile, &count, aoceText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kAOCE;
|
||||
rc = HSetFInfo(refNum, dirId, "\pAOCE", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with AOCE set: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "AOCE", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pICON", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pICON", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(customIconText);
|
||||
wRc = FSWrite(refFile, &count, customIconText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kHasCustomIcon;
|
||||
rc = HSetFInfo(refNum, dirId, "\pICON", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile has custom icon (not really): name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "ICON", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pSTATIONERY", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pSTATIONERY", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(stationeryText);
|
||||
wRc = FSWrite(refFile, &count, stationeryText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kIsStationery;
|
||||
rc = HSetFInfo(refNum, dirId, "\pSTATIONERY", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is stationery: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "STATIONERY", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pLOCKED", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pLOCKED", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(nameLockText);
|
||||
wRc = FSWrite(refFile, &count, nameLockText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kNameLocked;
|
||||
rc = HSetFInfo(refNum, dirId, "\pLOCKED", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is locked: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "LOCKED", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pBUNDLE", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pBUNDLE", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(bundleText);
|
||||
wRc = FSWrite(refFile, &count, bundleText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kHasBundle;
|
||||
rc = HSetFInfo(refNum, dirId, "\pBUNDLE", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile has bundle (not really): name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "BUNDLE", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pINVISIBLE", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pINVISIBLE", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(invisibleText);
|
||||
wRc = FSWrite(refFile, &count, invisibleText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kIsInvisible;
|
||||
rc = HSetFInfo(refNum, dirId, "\pINVISIBLE", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is invisible: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "INVISIBLE", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pALIAS", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pALIAS", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(aliasText);
|
||||
wRc = FSWrite(refFile, &count, aliasText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = kIsAlias;
|
||||
rc = HSetFInfo(refNum, dirId, "\pALIAS", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile is alias to nowhere: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "ALIAS", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pSIMPLE", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pSIMPLE", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(simpletextText);
|
||||
wRc = FSWrite(refFile, &count, simpletextText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostSimpleText;
|
||||
rc = HSetFInfo(refNum, dirId, "\pSIMPLE", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with creator SimpleText: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "SIMPLE", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pAARU", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pAARU", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(aaruText);
|
||||
wRc = FSWrite(refFile, &count, aaruText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostAaru;
|
||||
rc = HSetFInfo(refNum, dirId, "\pAARU", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with creator 'aaru': name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "AARU", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pPOS_M32_M32", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pPOS_M32_M32", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(pos_m32_m32);
|
||||
wRc = FSWrite(refFile, &count, pos_m32_m32);
|
||||
cRc = FSClose(refFile);
|
||||
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdLocation.h = -32768;
|
||||
finderInfo.fdLocation.v = -32768;
|
||||
rc = HSetFInfo(refNum, dirId, "\pPOS_M32_M32", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with position -32768,-32768: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n",
|
||||
"POS_M32_M32",
|
||||
rc,
|
||||
wRc,
|
||||
cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pPOS_32_32", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pPOS_32_32", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(pos_32_32);
|
||||
wRc = FSWrite(refFile, &count, pos_32_32);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdLocation.h = 32767;
|
||||
finderInfo.fdLocation.v = 32767;
|
||||
rc = HSetFInfo(refNum, dirId, "\pPOS_32_32", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with position 32767,32767: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "POS_32_32", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pPOS_M1_M1", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pPOS_M1_M1", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(pos_m1_m1);
|
||||
wRc = FSWrite(refFile, &count, pos_m1_m1);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdLocation.h = -1024;
|
||||
finderInfo.fdLocation.v = -1024;
|
||||
rc = HSetFInfo(refNum, dirId, "\pPOS_M1_M1", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with position -1024,-1024: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "POS_M1_M1", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pPOS_M1_M32", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pPOS_M1_M32", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(pos_m1_m32);
|
||||
wRc = FSWrite(refFile, &count, pos_m1_m32);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdLocation.h = -1024;
|
||||
finderInfo.fdLocation.v = -32768;
|
||||
rc = HSetFInfo(refNum, dirId, "\pPOS_M1_M32", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf(
|
||||
"\tFile with position -1024,-32768: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "POS_M1_M32", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pPOS_M1_32", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pPOS_M1_32", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(pos_m1_32);
|
||||
wRc = FSWrite(refFile, &count, pos_m1_32);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdLocation.h = -1024;
|
||||
finderInfo.fdLocation.v = 32767;
|
||||
rc = HSetFInfo(refNum, dirId, "\pPOS_M1_32", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with position -1024,32767: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "POS_M1_32", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pPOS_M1_1", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pPOS_M1_1", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(pos_m1_1);
|
||||
wRc = FSWrite(refFile, &count, pos_m1_1);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdLocation.h = -1024;
|
||||
finderInfo.fdLocation.v = 1024;
|
||||
rc = HSetFInfo(refNum, dirId, "\pPOS_M1_1", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with position -1024,1024: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "POS_M1_1", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pPOS_1_M1", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pPOS_1_M1", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(pos_1_m1);
|
||||
wRc = FSWrite(refFile, &count, pos_1_m1);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdLocation.h = 1024;
|
||||
finderInfo.fdLocation.v = -1024;
|
||||
rc = HSetFInfo(refNum, dirId, "\pPOS_1_M1", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with position 1024,-1024: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "POS_1_M1", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pPOS_1_M32", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pPOS_1_M32", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(pos_1_m32);
|
||||
wRc = FSWrite(refFile, &count, pos_1_m32);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdLocation.h = 1024;
|
||||
finderInfo.fdLocation.v = -32768;
|
||||
rc = HSetFInfo(refNum, dirId, "\pPOS_1_M32", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with position 1024,-32768: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "POS_1_M32", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pPOS_1_32", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pPOS_1_32", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(pos_1_32);
|
||||
wRc = FSWrite(refFile, &count, pos_1_32);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdLocation.h = 1024;
|
||||
finderInfo.fdLocation.v = 32767;
|
||||
rc = HSetFInfo(refNum, dirId, "\pPOS_1_32", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with position 1024,32767: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "POS_1_32", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pPOS_1_1", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pPOS_1_1", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(pos_1_1);
|
||||
wRc = FSWrite(refFile, &count, pos_1_1);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdLocation.h = 1024;
|
||||
finderInfo.fdLocation.v = 1024;
|
||||
rc = HSetFInfo(refNum, dirId, "\pPOS_1_1", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile with position 1024,1024: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "POS_1_1", rc, wRc, cRc);
|
||||
|
||||
memset(&finderInfo, 0, sizeof(FInfo));
|
||||
rc = HCreate(refNum, dirId, "\pALL", ostUnknown, ftGenericDocumentPC);
|
||||
if(!rc)
|
||||
{
|
||||
rc = HOpenDF(refNum, dirId, "\pALL", 0, &refFile);
|
||||
if(!rc)
|
||||
{
|
||||
count = strlen(allText);
|
||||
wRc = FSWrite(refFile, &count, allText);
|
||||
cRc = FSClose(refFile);
|
||||
finderInfo.fdType = ftGenericDocumentPC;
|
||||
finderInfo.fdCreator = ostUnknown;
|
||||
finderInfo.fdFlags = 0xFFFF;
|
||||
rc = HSetFInfo(refNum, dirId, "\pALL", &finderInfo);
|
||||
}
|
||||
}
|
||||
printf("\tFile has all flags bits set: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "ALL", rc, wRc, cRc);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,39 +5,20 @@
|
||||
#ifndef SETTER_SRC_MACOS_ATTR_H_
|
||||
#define SETTER_SRC_MACOS_ATTR_H_
|
||||
|
||||
const char* noAttributeText = "This file has all flags bits clear.\r";
|
||||
const char* desktopText = "This file is on desktop.\r";
|
||||
const char* color2Text = "This file is colored brown.\r";
|
||||
const char* color4Text = "This file is colored green.\r";
|
||||
const char* color6Text = "This file is colored lilac.\r";
|
||||
const char* color8Text = "This file is colored blue.\r";
|
||||
const char* colorAText = "This file is colored magenta.\r";
|
||||
const char* colorCText = "This file is colored red.\r";
|
||||
const char* colorEText = "This file is colored orange.\r";
|
||||
const char* requireSwitchText = "This file requires switch launch.\r";
|
||||
const char* sharedText = "This file is shared.\r";
|
||||
const char* noInitText = "This file contains no init.\r";
|
||||
const char* initedText = "This file has been inited.\r";
|
||||
const char* aoceText = "This file has AOCE bit set.\r";
|
||||
const char* customIconText = "This file has a custom icon.\r";
|
||||
const char* stationeryText = "This is a stationery.\r";
|
||||
const char* nameLockText = "This file has the name locked.\r";
|
||||
const char* bundleText = "This file has a BNDL resource.\r";
|
||||
const char* invisibleText = "This file is invisible.\r";
|
||||
const char* aliasText = "This file is an alias to nowhere.\r";
|
||||
const char* simpletextText = "This file has creator 'ttxt'.\r";
|
||||
const char* aaruText = "This file has creator 'aaru'.\r";
|
||||
const char* pos_m32_m32 = "This file position is -32k,-32k.\r";
|
||||
const char* pos_32_32 = "This file position is 32k,32k.\r";
|
||||
const char* pos_m1_m1 = "This file position is -1k,-1k.\r";
|
||||
const char* pos_m1_m32 = "This file position is -1k,-32k.\r";
|
||||
const char* pos_m1_32 = "This file position is -1k,32k.\r";
|
||||
const char* pos_m1_1 = "This file position is -1k,1k.\r";
|
||||
const char* pos_1_m1 = "This file position is 1k,-1k.\r";
|
||||
const char* pos_1_m32 = "This file position is 1k,-32k.\r";
|
||||
const char* pos_1_32 = "This file position is 1k,32k.\r";
|
||||
const char* pos_1_1 = "This file position is 1k,1k.\r";
|
||||
const char* allText = "This file has all flags bits set.\r";
|
||||
#include "macos.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* filename;
|
||||
char contents[170];
|
||||
char description[63];
|
||||
uint16_t flags;
|
||||
OSType type;
|
||||
OSType creator;
|
||||
Point location;
|
||||
} mac_attr_tests_t;
|
||||
|
||||
#define KNOWN_MAC_ATTRS 33
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -45,4 +26,236 @@ enum
|
||||
kAOCE = 0x0200
|
||||
};
|
||||
|
||||
static const mac_attr_tests_t mac_attrs[KNOWN_MAC_ATTRS] = {"\pNONE",
|
||||
"This file has all flags bits clear.\r",
|
||||
"File with no attributes",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pINDESK",
|
||||
"This file is on desktop.\r",
|
||||
"File is in desktop",
|
||||
kIsOnDesk,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pBROWN",
|
||||
"This file is colored brown.\r",
|
||||
"File is colored brown",
|
||||
0x02,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pGREEN",
|
||||
"This file is colored green.\r",
|
||||
"File is colored green",
|
||||
0x04,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pLILAC",
|
||||
"This file is colored lilac.\r",
|
||||
"File is colored lilac",
|
||||
0x06,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pBLUE",
|
||||
"This file is colored blue.\r",
|
||||
"File is colored blue",
|
||||
0x08,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pMAGENTA",
|
||||
"This file is colored magenta.\r",
|
||||
"File is colored magenta",
|
||||
0x0A,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pRED",
|
||||
"This file is colored red.\r",
|
||||
"File is colored red",
|
||||
0x0C,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pORANGE",
|
||||
"This file is colored orange.\r",
|
||||
"File is colored orange",
|
||||
0x0E,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pSWITCH",
|
||||
"This file requires switch launch.\r",
|
||||
"File require switch launch",
|
||||
kRequireSwitchLaunch,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pSHARED",
|
||||
"This file is shared.\r",
|
||||
"File is shared",
|
||||
kIsShared,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pNOINIT",
|
||||
"This file contains no init.\r",
|
||||
"File has no INITs",
|
||||
kHasNoINITs,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pINITED",
|
||||
"This file has been inited.\r",
|
||||
"File has been INITed",
|
||||
kHasBeenInited,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pAOCE",
|
||||
"This file has AOCE bit set.\r",
|
||||
"File with AOCE set",
|
||||
kAOCE,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pICON",
|
||||
"This file has a custom icon.\r",
|
||||
"File has custom icon (not really)",
|
||||
kHasCustomIcon,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pSTATIONERY",
|
||||
"This is a stationery.\r",
|
||||
"File is stationery",
|
||||
kIsStationery,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pLOCKED",
|
||||
"This file has the name locked.\r",
|
||||
"File is locked",
|
||||
kNameLocked,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pBUNDLE",
|
||||
"This file has a BNDL resource.\r",
|
||||
"File has bundle (not really)",
|
||||
kHasBundle,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pINVISIBLE",
|
||||
"This file is invisible.\r",
|
||||
"File is invisible",
|
||||
kIsInvisible,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pALIAS",
|
||||
"This file is an alias to nowhere.\r",
|
||||
"File is alias to nowhere",
|
||||
kIsAlias,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0},
|
||||
"\pSIMPLE",
|
||||
"This file has creator 'ttxt'.\r",
|
||||
"File with creator SimpleText",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostSimpleText,
|
||||
{0, 0},
|
||||
"\pAARU",
|
||||
"This file has creator 'aaru'.\r",
|
||||
"File with creator 'aaru'",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostAaru,
|
||||
{0, 0},
|
||||
"\pPOS_M32_M32",
|
||||
"This file position is -32k,-32k.\r",
|
||||
"File with position -32768,-32768",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{-32768, -32768},
|
||||
"\pPOS_32_32",
|
||||
"This file position is 32k,32k.\r",
|
||||
"File with position 32767,32767",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{32767, 32767},
|
||||
"\pPOS_M1_M1",
|
||||
"This file position is -1k,-1k.\r",
|
||||
"File with position -1024,-1024",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{-1024, -1024},
|
||||
"\pPOS_M1_M32",
|
||||
"This file position is -1k,-32k.\r",
|
||||
"File with position -1024,-32768",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{-32768, -1024},
|
||||
"\pPOS_M1_32",
|
||||
"This file position is -1k,32k.\r",
|
||||
"File with position -1024,32767",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{32767, -1024},
|
||||
"\pPOS_M1_1",
|
||||
"This file position is -1k,1k.\r",
|
||||
"File with position -1024,1024",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{1024, -1024},
|
||||
"\pPOS_1_M1",
|
||||
"This file position is 1k,-1k.\r",
|
||||
"File with position 1024,-1024",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{-1024, 1024},
|
||||
"\pPOS_1_M32",
|
||||
"This file position is 1k,-32k.\r",
|
||||
"File with position 1024,-32768",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{-32768, 1024},
|
||||
"\pPOS_1_32",
|
||||
"This file position is 1k,32k.\r",
|
||||
"File with position 1024,32767",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{1024, 32767},
|
||||
"\pPOS_1_1",
|
||||
"This file position is 1k,1k.\r",
|
||||
"File with position 1024,1024",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{1024, 1024},
|
||||
"\pALL",
|
||||
"This file has all flags bits set.\r",
|
||||
"File has all flags bits set",
|
||||
0,
|
||||
ftGenericDocumentPC,
|
||||
ostUnknown,
|
||||
{0, 0}};
|
||||
|
||||
#endif // SETTER_SRC_MACOS_ATTR_H_
|
||||
|
||||
Reference in New Issue
Block a user