21.07.2015 Views

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

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.

Appendix C: Implementation Notes 293"blocks""atime""mtime""ctime""pmode"The number of disk blocks the file actually occupies. This may not be a functionof the file’s size if the file has holes.The file’s last access, modification, and inode update times, respectively. Theseare numeric timestamps, suitable for formatting with strftime (see Section 8.1[Built-in Functions], page 130).The file’s “printable mode.” This is a string representation of the file’s type andpermissions, such as what is produced by ‘ls -l’—for example, "drwxr-xr-x"."type" A printable string representation of the file’s type. The value is one of thefollowing:"blockdev""chardev"The file is a block or character device (“special file”)."directory"The file is a directory."fifo""file""socket""symlink"The file is a named-pipe (also known as a FIFO).The file is just a regular file.The file is an AF_UNIX (“Unix domain”) socket in the filesystem.The file is a symbolic link.Several additional elements may be present depending upon the operating system andthe type of the file. You can test for them in your awk program by using the in operator(see Section 7.2 [Referring to an Array Element], page 120):"blksize""linkval""rdev""major""minor"The preferred block size for I/O to the file.POSIX-like systems in the C stat structure.This field is not present on allIf the file is a symbolic link, this element is the name of the file the link pointsto (i.e., the value of the link).If the file is a block or character device file, then these values represent thenumeric device number and the major and minor components of that number,respectively.C.3.2.2 C Code for chdir and statHere is the C code for these extensions. They were written for GNU/Linux. The code needssome more work for complete portability to other POSIX-compliant systems: 11 This version is edited slightly for presentation. The complete version can be found in‘extension/filefuncs.c’ in the gawk distribution.

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

Saved successfully!

Ooh no, something went wrong!