File Attributes

Table Of All Supported Attributes

name of attributereturn typedescriptionPOSIXWin32Mac OS
filenamestring_typethe name of the file or directoryrw
hiddenboolwhether the file is hidden or visibler (filename starts with '.')
POSIX file types (see POSIX documentation for further informations)
is_directoryboolwhether the file is a directoryr
is_regularboolthis is a regular filer
is_linkboolr
is_char_deviceboolr
is_block_deviceboolr
is_fifoboolr
is_socketboolr
POSIX members of stat
sizeoff_ttotal file size (characters)r
block_sizeblksize_tblocksize for filesystem I/Or
blocksblkcnt_tnumber of blocks allocatedr
devicedev_tdevicer
inodeino_tinoder
no_linksnlink_tnumber of hard linksr
rdevdev_tdevice type (if inode device)r
times
access_timestd::time_ttime of last accessrw
modification_timestd::time_ttime of last modificationrw
change_timestd::time_ttime of last changer
permissions for user
set_uidboolwhether the UID bit is setrw
user_readboolrw
user_writeboolrw
user_executeboolrw
user_iduid_tuser ID of ownerrw
user_namestring_typeuser name of ownerrw
permissions for group
set_gidboolwhether the GID bit is setrw
group_readboolrw
group_writeboolrw
group_executeboolrw
group_idgid_tgroup ID of ownerrw
group_namestring_typegroup name of ownerrw
permissions for others
stickyboolwhether the sticky bit is setrw
others_readboolrw
others_writeboolrw
others_executeboolrw
r

The protection member of stat (according to POSIX) is not supported since it can be accessed via the permission attributes like user_read, etc.

Return Types

The return type of filename, user_name and group_name is boost::filesystem::string_type.
off_t, blksize_t, blkcnt_t, dev_t, ino_t, nlink_t, uid_t and gid_t are defined in boost::filesystem::sys_types. They are typedefs to corresponding types provided by the underlying operating system.

Requirements

All implemented attributes meet some requirements which should also be met by user defined new file attributes:

User Defined Attributes

The user can define its own file attributes but they must meet the requirements above. There are only a few things which are guaranteed in the interface of entry_rep. One is the method string_type entry_rep::entry () which returns the name of the file. The following example uses this method to return whether the filename starts with a specific letter:
	template <char_type C>
	class first_letter {
	public:
		typedef bool value_type;
		
		static bool is_specialized () {
			return true;
		}
		static bool is_readable () {
			return true;
		}
		static bool is_writeable () {
			return false;
		}
		
		static value_type get (entry_rep const &r) {
			return (!r.entry ().empty () && r.entry () [0] == C);
		}
	};
and it can be used to copy all files with names starting with 'a' into a vector:
	std::vector  v;
	boost::filesystem::dir_it i ("."), end;
	for (; i != end; ++i) {
		if (boost::filesystem::get <first_letter <'a'> > (i)) {
			v.push_back (*i);
		}
	}