Part II - Temporary badging on Files and Folders.What is wrong in the code attached?
Part II - Temporary badging on Files and Folders.What is wrong in the code attached?
- Subject: Part II - Temporary badging on Files and Folders.What is wrong in the code attached?
- From: Manish Pattath <email@hidden>
- Date: Sat, 6 Nov 2004 11:45:09 +0000 (GMT)
//Removal Of the Badge from Folder , Contination from Part1
int RemoveBadge ( char *path)
{
FSCatalogInfo info;
FSRef pToFSRef;
FSRef pToFSRef2;
Boolean isDirectory = false;
OSErr err = noErr;
if (nil == path)
return 1;
if (FSPathMakeRef(path,&pToFSRef,&isDirectory) == noErr)
{
HFSUniStr255 fork;
SInt16 refnum = kResFileNotOpened;
FSGetResourceForkName(&fork);
if (isDirectory)
{
memset(&info,0,sizeof(info));
((FileInfo*)(&info.finderInfo))->finderFlags = kIsInvisible;
err = FSMakeFSRefUnicode(&pToFSRef,8,(UniChar*)"\000I\000c\000o\000n\000\r",kTextEncodingUnknown,&pToFSRef2);
// if (err!=noErr)
//!
return
1;
}
else
{
BlockMoveData(&pToFSRef,&pToFSRef2,sizeof(FSRef));
}
err = FSOpenResourceFile(&pToFSRef2,fork.length,fork.unicode,fsRdWrPerm,&refnum);
if(err!=noErr)
return 1;
if (refnum!=kResFileNotOpened)
{
// First remove existing badge
CustomBadgeResource **cbr = (CustomBadgeResource**) Get1Resource(kCustomBadgeResourceType,kCustomBadgeResourceID);
if (cbr)
{
if (GetHandleSize((Handle)cbr) >= sizeof(CustomBadgeResource))
{
if ((**cbr).version == kCustomBadgeResourceVersion)
{
Handle h = Get1Resource(kIconFamilyType,(**cbr).customBadgeResourceID);
if
(h)
{
RemoveResource(h);
WriteResource(h);
ReleaseResource(h);
}
}
}
RemoveResource((Handle)cbr);
DisposeHandle((Handle)cbr);
UpdateResFile(refnum);
CloseResFile(refnum);
if (FSGetCatalogInfo(&pToFSRef,kFSCatInfoFinderXInfo,&info,NULL,NULL,NULL)==noErr)
{
((ExtendedFileInfo*)(&info.extFinderInfo))->extendedFinderFlags = kExtendedFlagsAreInvalid ;
FSSetCatalogInfo(&pToFSRef,kFSCatInfoFinderXInfo,&info);
}
MoreFEUpdateItemFSRef(&pToFSRef);
}
}
}
return 1 ;
}
Any Help will be greatly appreciated. Thanks.
Yahoo! India Matrimony: Find your life partner
online.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden