• 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: Reading file permissions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading file permissions


  • Subject: Re: Reading file permissions
  • From: Ed Watkeys <email@hidden>
  • Date: Wed, 26 Nov 2003 14:42:58 -0500

Here's a class method you can add to a class to print out an extended "ls -l" style permission string:

+ (NSString *)stringFromPermissions:(int) p {
char s[12];
strmode(p, s);
return [NSString stringWithUTF8String: s];
}

You can call it like this:

NSLog(@"%@", [YourClass stringFromPermissions: 0755]);

It uses strmode(). I found this by looking at the source code for "ls". On a related note, if you want the octal representation of a number, do this:

NSLog(@"%@", [NSString stringWithFormat: @"%o", 0644]);

I found out how to use "%o" by typing "man 3 printf" at the command line. You could also have gotten to equivalent documentation by looking at the Apple's documentation for NSString's stringWithFormat: class method.

Ed
_______________________________________________
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: 
 >Re: Reading file permissions (From: David Kocher <email@hidden>)

  • Prev by Date: Re: Reading file permissions
  • Next by Date: Re: ZeroLink and dynamic discovered Classes
  • Previous by thread: Re: Reading file permissions
  • Next by thread: setting up nextKeyView chain dynamically
  • Index(es):
    • Date
    • Thread