Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set file Read Only...

13 views
Skip to first unread message

Fon...@gmail.com

unread,
Mar 22, 2007, 8:13:12 AM3/22/07
to

Hello there!

I'm trying to port some code to new Carbon API... And working on
function which can set ReadOnly file attirbute.
In old code I had somesing like this to reset ReadOnly attribute:

error = HRstFLock(fsSpec.vRefNum, fsSpec.parID,
_CtoPstr(thetext));
error = FSpRstFLock(&fsSpec);

I'm not sure that this code worked fine...
Currentrly I'm learning FSSetCatalogInfo function and don't know what
should I do...

This code doesn't work:

HFSUniStr255 outName;
FSSpec fsSpec;
FSRef parentRef;
FSCatalogInfo catalogInfo;

error = FSGetCatalogInfo(&fsRefFile, NULL, &catalogInfo, &outName,
&fsSpec, &parentRef);

if ( catalogInfo.nodeFlags & kFSNodeLockedMask)
{
UInt16 uiFlagMask = kFSNodeLockedMask;
uiFlagMask = ~uiFlagMask;
catalogInfo.nodeFlags = catalogInfo.nodeFlags & (uiFlagMask); //
Turn off flag
error = FSSetCatalogInfo( &fsRefFile, NULL, (const
FSCatalogInfo*)&catalogInfo);
}

I'm using finder, and it show that file is still ReadOnly...

David Phillip Oster

unread,
Mar 22, 2007, 11:39:07 AM3/22/07
to
In article <1174565592....@n59g2000hsh.googlegroups.com>,
Fon...@gmail.com wrote:

That bit controls the [] Locked checkbox, high in the Finder's Info
window. To control the "read only" popup, low in the window, you must
use some equivalent of chmod() from the System framework, which takes a
POSIX path.

Gregory Weston

unread,
Mar 22, 2007, 7:41:03 PM3/22/07
to
In article <oster-96CD57....@newsclstr02.news.prodigy.com>,

FSSetCatalogInfo can also change the permissions. The FSCatalogInfo
structure has a permissions field that can be interpreted as a
FSPermissionInfo structure. You'd want the kFSCatInfoPermissions flag in
the whichInfo argument.


Um. Now that I look at it, one major reason that the above code isn't
working would be that you're passing 0 for that argument in both the Get
and Set functions.

Fon...@gmail.com

unread,
Mar 23, 2007, 12:00:52 PM3/23/07
to

David & Gragory thanks very much!

1.) It's look like that chmod works fine.

2.) And what about FSCatalogInfo, "permissions" field - represent
FSPermissionInfo struct. I think it's better to copy from
"permissions" into local variable of type FSPermissionInfo, and than
change it, and copy back...
In FSPermissionInfo I should change mode fileld, as in chmod function?

What is the best way, and more safely???

Thanks!

0 new messages