How to change file permissions from Carbon ?

Saturday, November 22 2003 @ 08:59 AM UTC

Contributed by: Admin

Is there a call to access and modify Unix file permission bits ?

OSErr SetFilePermissions( FSRef * ref, UInt32 perm )
{
  FSCatalogInfo  catInfo;
  OSErr err ;

  if ( noErr == (err = FSGetCatalogInfo( ref, kFSCatInfoPermissions, &catInfo, 0, 0, 0 )) )
  {
    catInfo.permissions[2] = (catInfo.permissions[2] & 0xFFFFFE00) | (perm & 0x1FF); // mask off low 9 bits and replace with new ones
    return FSSetCatalogInfo( ref, kFSCatInfoPermissions, &catInfo );
  }
  return err ;
}

0 comments



http://www.macosxguru.net/article.php?story=20031122085934409