Description
This article is from the Mac Programming
FAQ, by Jon Watte h+@austin.metrowerks.com with numerous
contributions by others.
4.10) How do I make the Finder see a new file that I created? Or if I changed the type of it; how do I display a new icon for it? (Files - Mac Programming)
You call (surprise!) PBGetCatInfo followed by PBSetCatInfo for the
FOLDER the file is in. Inbetween, you should set ioDrMdDat to the
current date&time. Code:
*code*
OSErr
TouchFolder ( short vRefNum , long parID ) {
CInfoPBRec rec ;
Str63 name ;
short err ;
rec . hFileInfo . ioNamePtr = name ;
name [ 0 ] = 0 ;
rec . hFileInfo . ioVRefNum = vRefNum ;
rec . hFileInfo . ioDirID = parID ;
rec . hFileInfo . ioFDirIndex = -1 ;
rec . hFileInfo . ioFVersNum = 0 ;
err = PBGetCatInfoSync ( & rec ) ;
if ( err ) {
return err ;
}
GetDateTime ( & rec . dirInfo . ioDrMdDat ) ;
rec . hFileInfo . ioVRefNum = vRefNum ;
rec . hFileInfo . ioDirID = parID ;
rec . hFileInfo . ioFDirIndex = -1 ;
rec . hFileInfo . ioFVersNum = 0 ;
rec . hFileInfo . ioNamePtr [ 0 ] = 0 ;
err = PBSetCatInfoSync ( & rec ) ;
return err ;
}
*end*
 
Continue to:
Share and Enjoy
Bookmark this story so others can enjoy it:
Tags
os, Mac, macintosh, apple, programming, software