The file to get the attributes of.
The attributes of the file as a uint.
FileException on error.
getAttributes with a file
import std.exception : assertThrown; auto f = deleteme ~ "file"; scope(exit) f.remove; assert(!f.exists); assertThrown!FileException(f.getAttributes); f.write("."); auto attributes = f.getAttributes; assert(!attributes.attrIsDir); assert(attributes.attrIsFile);
getAttributes with a directory
import std.exception : assertThrown; auto dir = deleteme ~ "dir"; scope(exit) dir.rmdir; assert(!dir.exists); assertThrown!FileException(dir.getAttributes); dir.mkdir; auto attributes = dir.getAttributes; assert(attributes.attrIsDir); assert(!attributes.attrIsFile);
Returns the attributes of the given file.
Note that the file attributes on Windows and POSIX systems are completely different. On Windows, they're what is returned by GetFileAttributes, whereas on POSIX systems, they're the st_mode value which is part of the stat struct gotten by calling the stat function.
On POSIX systems, if the given file is a symbolic link, then attributes are the attributes of the file pointed to by the symbolic link.