O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

File Metadata

File metadata is data about the file, but it is not the file’s data itself. This includes information like the file’s size, type, the last access times, and so on.

stat()

Three functions can be used to access metadata that lives in the inode:

int stat (const char *path, struct stat *sb);

int lstat (const char *path, struct stat *sb);

int fstat (int fd, struct stat *sb);

stat() gets the status, the information about the file at a path, following any intervening symbolic links. lstat() gets information about the symbolic link itself. fstat() gives you metadata about an already open file. As with most Unix file functions, a return value of zero indicates success, a value of -1 indicates an error, and errno is set appropriately.

You ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required