13.07.2015 Views

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 5: Using the Filesystem 113to folders is used to specify search permission, namely the ability to obtain a list of the folder’scontents. Search permission is not required to test for the existence of a named file, but it isrequired in order to scan the contents of a given folder.UNIX (or more correctly POSIX) permission information is typically provided by the programmerusing a bitfield represented using octal numbers (where each digit can be between 0 and 7,using three bits per digit). Each permission has a single bit associated with it, and each digitrefers to the user, group, and other. Within each digit, the three bits represent, from left to right(so, most to least significant bit), the read, write, and execute permissions. Therefore the value0755 (remember that to type octal values in C and <strong>Objective</strong>-C you type the number with aleading zero) sets all three bits (7 octal = 111 binary) for the user, meaning the user can read,write, and execute the file. The group and other sections set only the read and execute bits(5 octal = 101 binary), so you can see that only the owner of the file can change its contents.This information is visible from the command line using the ls -l command (ls = list, -l = longformat), where it is presented in a more readable format, as shown in Listing 5-2. The first entryon each line describes the file’s type, permissions, and some attributes.Listing 5-2. File and Folder Attributes on the Command LineLP-347 ~ " ls -ltotal 8drwx------+ 12 jdovey 204937174 408 3 Jun 20:12 Desktopdrwx------+ 38 jdovey 204937174 1292 2 Jun 14:50 Documentsdrwx------+ 4 jdovey 204937174 136 3 Jun 19:20 <strong>Download</strong>sdrwx------@ 31 jdovey 204937174 1054 2 Jun 13:29 Dropboxdrwx------@ 43 jdovey 204937174 1462 4 Jun 08:24 Librarydrwx------+ 3 jdovey 204937174 102 1 Jun 16:01 Moviesdrwx------+ 3 jdovey 204937174 102 1 Jun 16:01 Musicdrwx------+ 8 jdovey 204937174 272 1 Jun 23:54 Picturesdrwxr-xr-x+ 4 jdovey 204937174 136 1 Jun 16:01 Publicdrwxr-xr-x@ 4 jdovey 204937174 136 23 Aug 2010 ScriptsLP-347 ~ "The first letter tells you the type of the item; in this case d indicates that the item is a directory(folder). A regular file has a type of -, symbolic links use l, sockets use s, and there are othersthat you are even less likely to encounter. Following this is a group of nine characters, in threegroups of three. These specify the read (r), write (w), and execute/search (x) privileges for theuser, group, and other users respectively. If a privilege is granted, its letter appears in theappropriate slot; otherwise its slot contains a hyphen (-) character. You can see that most itemsin Listing 5-2 are folders that are only readable, writable, and searchable by their owner. Thelast two items, Public and Scripts, are also readable and searchable by members of the samegroup and any other users.Following the permissions fields is one more character, which is used to denote extra informationavailable. In this case, some items specify the @ character, denoting extended attributes are set(more on those shortly), while others have the + character, informing you that an access controllist is set on that item, which leads nicely into the next type of permission data.Access Control Lists (or ACLs) are used to specify a larger number of permissions in a muchmore granular manner. For instance, you can use ACLs to grant or deny privileges to specificusers and groups, and you can grant or deny privileges not just for reading, writing, andwww.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!