• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Q] Unlocking an arbitrary file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] Unlocking an arbitrary file?


  • Subject: Re: [Q] Unlocking an arbitrary file?
  • From: Clark Mueller <email@hidden>
  • Date: Tue, 24 Sep 2002 20:38:20 -0600

Here's some code to set locked bit's state. You need to include the
CoreServices/Carbon framwork into your app for this code to work.

- (BOOL)setFile:(NSString *)file isLocked:(BOOL)isLocked{
// Sets or clears 'file''s locked bit.

const FSSpec spec = [self getFSSpec:file];
OSErr err;

if(isLocked){
err = FSpSetFLock(&spec);
}
else{
err = FSpRstFLock(&spec);
}

if( err != noErr ){
return NO;
}

return YES;
}

Good luck,

Clark

On Tuesday, September 24, 2002, at 08:19 PM, Ando Sonenblick wrote:

> Gang,
>
> I9m looking to make a simple app that will take any files dragged onto
> it
> and unlock them. I want this because OSX doesn9t seem to have any
> feature
> like OS9 did: hold down the option key while emptying the trash to
> allow it
> to toss locked files -- unless any of you know how to get the Finder
> to do
> this? I searched, tried all sorts of stuff, asked around but to no
> avail.
>
> Anwyay, going on the assumption that I9ll need to write an app, I
> researched
> around but only seem to have uncovered pitfalls and not solutions:
>
> Narrowing in on this method (of NSFileManager):
>
> - (BOOL)changeFileAttributes:(NSDictionary *)attributes
> atPath:(NSString
> *)path
>
> I discover that:
>
> (Problem 1) - 3Attributes that you can change are the owner, group,
> file
> permissions, and modification date.2 It doesn9t look like I can
> change the
> immutable attribute, which I9m presuming is the lock bit -
> documentation
> wasn9t helpful - am I mistaken?
>
> Furthermore:
>
> (Problem 2) - 3As in the POSIX standard, the application must either
> own the
> file or directory or must be running as superuser for attribute
> changes to
> take effect.2
>
> Ack! Being still relatively new to Unix, I don9t know what (if?) I9ll
> need
> to do to make my app run as superuser or otherwise have permission to
> tweak
> a file9s attributes...
>
> So... Can anyone either inform me of a different approach to unlock any
> file? Or provide insight on solving either of the two problems I9ve
> encountered?
>
> Much appreciated,
> Ando
> _______________________________________________
> 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.
_______________________________________________
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.

References: 
 >[Q] Unlocking an arbitrary file? (From: Ando Sonenblick <email@hidden>)

  • Prev by Date: Re: How to make DO not do transformations
  • Next by Date: Drawer larger than the window?
  • Previous by thread: [Q] Unlocking an arbitrary file?
  • Next by thread: Re: [Q] Unlocking an arbitrary file?
  • Index(es):
    • Date
    • Thread