in Apps, Cocoa, Mac OS X, Objective-C

Calculating UNIX file permissions

Permissions Mac AppA few years ago I wrote a simple but handy Mac app that calculates unix file permissions using a matrix of check boxes. I wrote it because I wanted to better understand how those octal values get calculated and to expand my experience of writing Mac apps.

I was also learning some crazy assembly code at the time too so I was also making sense of putting bitwise operations to task. Rather than let this code languish on my hard drive, I thought I’d share…

The main nib file contains a matrix with the the button cells set to a check box style. The whole matrix has an action attached that calls the AppController’s calculatePermission: method. This method is quite simple and I’ve carefully commented it for you so please feel free to check it out. It loops around the matrix and bitwise OR up the checkbox values and then converts this into a C string. I decided to use a C string because the text version of the permissions can only be ASCII values and we might as well be as efficient as possible.

I’ve uploaded Permissions to GitHub in the hope that someone might find it useful when they’re learning Cocoa. If you do find it helpful please post a quick comment. Feedback is always appreciated.

Write a Comment

Comment

  1. There seems to be no license listing on the github version. Can you add a license of some sort so it is clear?