Re: Change Unix Permissions
Re: Change Unix Permissions
- Subject: Re: Change Unix Permissions
- From: Lorenzo Puleo <email@hidden>
- Date: Tue, 05 Nov 2002 15:25:04 +0100
Hi,
I have just tried and I was able to set rwxrwxrwx file permissions using the
FSSetCatalogInfo call. Why do you say that I can't? Maybe sometimes in some
conditions I can't?
Also, I would like to say wath I really I have to do.
I have to copy the source file /A/x.txt, say locked (by the "Get Info" panel
in the Finder) and ReadOnly (r-xr-xr-x), to /B/x.txt
The destination file should have the same following data of the source file:
- Creation Date
- Modification Date
- Backup Date
- Locked flag
- FinderInfo
- Permissions
- Owner
- Group
Running as root I should be able to set all the data to the destination
file. Running as simple user I should be able to set all the data but Ower
and Group. Let's say I run as root.
First I use the following API to copy the file
ok = [manager copyPath:source toPath:dest handler:nil];
After the copyPath executes the copy I obtain the /B/x.txt file unlocked
and ReadOnly.
Then I have to set all the data.
Please remember that the source file is Locked and ReadOnly (r-xr-xr-x).
Consider that the API
[manager changeFileAttributes:destAttribute atPath:dest];
doesn't let me set the backup date of the destination file because the
dictionary has not that data. The same is for the "Locked" flag.
Thus I have to use the API FSSetCatalogInfo to set the backup date and the
"Locked" flag.
But first I have to set the permission to ReadAndWrite in order to change
the "Locked" flag this way:
[destAttribute setObject:[NSNumber numberWithInt:511]
forKey:@"NSFilePosixPermissions"];
It works properly.
Now, if I first set the "Locked" flag using the FSSetCatalogInfo call
err = FSSetCatalogInfo(&destRef, kFSCatInfoBackupDate | kFSCatInfoNodeFlags,
&theInfo);
then I can't set the other data anymore using the API changeFileAttributes
because the destination file is locked.
Other hand, if I first set the permissions using the API
changeFileAttributes, and the source permissions are ReadOnly, then I can't
set the "Locked" flag anymore because the destination file is ReadOnly.
Then I think I have to set all the data in one shot only using the
FSSetCatalogInfo call that way:
err = FSSetCatalogInfo(&destRef, kFSCatInfoCreateDate | kFSCatInfoContentMod
| kFSCatInfoPermissions | kFSCatInfoBackupDate | kFSCatInfoNodeFlags |
kFSCatInfoFinderInfo, &theInfo);
It seems to work properly, thus I would like to know the reason why you say
that it could set wrong permissions.
May you let me know please?
--
Lorenzo Puleo
mailto:email@hidden
>
From: Stiphane Sudre <email@hidden>
>
Date: Mon, 4 Nov 2002 18:00:40 +0100
>
To: Lorenzo Puleo <email@hidden>
>
Subject: Re: Change Unix Permissions
>
>
>
On lundi, nov 4, 2002, at 17:39 Europe/Paris, Lorenzo Puleo wrote:
>
>
> Hi,
>
> thank you.
>
> What does it mean?
>
>> 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.
>
>
>
> First I copy a file, and the just copied file is Read&Write for all the
>
> users. Then I set the permissions. Should it work? On Mac and no-Mac?
>
>
It means that if you want to set the following file permisions:
>
rwxrwxrwx, using the FSSetCatalogInfo call, you would get:
>
>
rwxr_xr_x
>
>
Which is a bit different from what you expect.
_______________________________________________
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.