This preview shows page 1. Sign up to view the full content.
Unformatted text preview: rence between text ﬁles and binary ﬁles. A directory ﬁle contains information about other ﬁles. And a socket is a ﬁle that is used to communicate with another process across a network. Unix provides macro predicates for determining the ﬁle type. Figure 12.18 shows a subset. Each ﬁle type macro takes an st mode member as its argument.
Macro S ISREG() S ISDIR() Description Is this a regular ﬁle? Is this a directory ﬁle? Figure 12.18: Some macros for determining the type of ﬁle. Deﬁned in sys/stat.h 626 CHAPTER 12. NETWORK PROGRAMMING The protection bits in st mode can be tested using the bit masks in Figure 12.19. For example, the followst mode mask S IRUSR S IWUSR S IXUSR S IRGRP S IWGRP S IXGRP S IROTH S IWOTH S IXOTH Description User (owner) can read this ﬁle User (owner) can write this ﬁle User (owner) can execute this ﬁle Group members can read this ﬁle Group members can write this ﬁle Group members can execute this ﬁle Others (anyone) can read this ﬁle Others (anyone) can write this ﬁle Others (anyone) can execute this ﬁle Figure 12.19: Masks for checking protection bits. Deﬁned in sys/stat.h ing code fragment checks if the current process has permiss...
View Full Document
This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.
- Spring '10
- The American