[darcs-devel] [darcs #156] Strange darcs file-writing bug on Mac OS X

Guillaume guillaume.outters at free.fr
Sat Jan 1 17:20:10 PST 2005


Le 1 janv. 2005, à 15:46, David Roundy a écrit :

> On Tue, Dec 28, 2004 at 10:52:23PM +0100, Guillaume wrote:
>
>> This could be due to HFS permissions, that complement Unix ones.
>
> Is there an API we could use to set this, if this turns out to be the
> problem? If so, could you send a pointer to where to find the docs for  
> such
> an API? Or perhaps some trick we could use to make sure things are set
> "right"?

OK, here is some C code to read and reset the "locked" attribute of a  
file. It deals with Carbon, which is the archeologists-interesting API  
of Mac OS X, has never been very elegant and moreover has gained weight  
to add compatibility layers between pre-X Mac OS and the whole soup of  
BSD and NeXT APIs.

The documentation about this can be found at  
<http://developer.apple.com/documentation/Carbon/Reference/ 
File_Manager/index.html>.

I'll add a Cocoa version to that, which is the "more native" API and in  
Objective C (Java anyone?). I haven't found and thus verified which of  
the calls I make are more portable towards old Mac OS X (Public Beta,  
or at least 10.0). That I'm uncertain about this, and the necessary  
addition of an NSAutoreleasePool (which collects reference-counted  
objects), are the two reasons why I include the Carbon pure C version  
too.

The reference for this part of Cocoa is at  
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ 
ObjC_classic/Classes/NSFileManager.html>.

So here we go, compile with:
cc -o c -D CARBON_UNLOCK c.m -framework Carbon
or:
cc -o c c.m -framework Cocoa
Those await all your strings to be in UTF-8 (at least I think; this  
sould be verified on a system where the locale has another charset).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: c.m
Type: application/octet-stream
Size: 2277 bytes
Desc: not available
Url : http://lists.osuosl.org/pipermail/darcs-devel/attachments/20050102/3f3e37f3/c.obj
-------------- next part --------------


Now if someone on the lists could have access to a machine with an old 
version of Mac OS X, he or she would be welcome to test for 
compatibility (take any file to /tmp, in a Terminal "open /tmp", in the 
Finder Command-I to get info on this file (named "pimpim.pouet") and 
check "locked", in the Terminal run ./c /tmp/pimpim.pouet twice; the 
first time should give a 1 (locked), the second time a 0 (unlocked) and 
the Finder info window should reflect this. Of course a segmentation 
fault before completion would be a major problem for compatibility 
acceptance).

-- 
Guillaume


More information about the darcs-devel mailing list