Re: Change Unix Permissions
Re: Change Unix Permissions
- Subject: Re: Change Unix Permissions
- From: Stéphane Sudre <email@hidden>
- Date: Mon, 4 Nov 2002 16:50:36 +0100
On lundi, nov 4, 2002, at 16:33 Europe/Paris, Lorenzo Puleo wrote:
Hi,
I have to change the permissions to a file in my Cocoa application,
but I
would avoid to use:
[manager changeFileAttributes:destAttribute atPath:destFile];
I would like to use the Carbon routines. All I have to do is:
1) First I read the permissions
err = FSGetCatalogInfo(&destRef, kFSCatInfoSettableInfo, &theInfo,
nil, nil,
nil);
2) And then I want to change only the Owner permissions r-x to rwx
using the
following:
err = FSSetCatalogInfo(&destRef, kFSCatInfoPermissions, &theInfo);
because in one only API, here I can set FinderFlags, Dates, etc...
So please, how should I use the variable "theInfo.permissions" either
for
understanding the original permissions and for setting the new
permissions?
==========================
From the Carbon archives:
==========================
#define kGroupReadMask 0x0040
>> #define kGroupWriteMask 0x0020
>> #define kGroupAccessMask 0x0010
>> #define kEveryoneReadMask 0x0004
>> #define kEveryoneWriteMask 0x0002
>> #define kEveryoneAccessMask 0x0001
>>
>> FSRef itemRef;
>> FSCatalogInfo catalogInfo;
>> FSPermissionInfo* permPtr;
>> OSErr status;
>>
>> status = ::FSGetCatalogInfo( &itemRef, kFSCatInfoPermissions,
>> &catalogInfo, NULL, NULL, NULL ); // get current info
>>
>> // Get the current setting and adjust it.
>> permPtr = (FSPermissionInfo*)&catalogInfo.permissions;
>> permPtr->mode |= ( kGroupReadMask | kGroupWriteMask |
>> kEveryoneReadMask | kEveryoneWriteMask );
>>
>> status = ::FSSetCatalogInfo( &itemRef, kFSCatInfoPermissions,
-----------------
Also, will this work on no-Mac FileSystems?
It might not work as you want it to even on Mac FileSystems as the
FSSetCatalogInfo API is using the User Mask to set the file permissions.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.