lotus



previous page: 4.9) How do I find the name of a folder for which I only know the dirID and vRefNum? (Files - Mac Programming)
  
page up: Mac Programming FAQ
  
next page: 4.11) Aren't we done with PBGetCatInfo soon? (Files - Mac Programming)

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)




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:















TOP
previous page: 4.9) How do I find the name of a folder for which I only know the dirID and vRefNum? (Files - Mac Programming)
  
page up: Mac Programming FAQ
  
next page: 4.11) Aren't we done with PBGetCatInfo soon? (Files - Mac Programming)