win32file.GetFileAttributesEx
tuple = GetFileAttributesEx(FileName, InfoLevelId
, Transaction
)
Retrieves attributes for a specified file or directory.
Parameters
FileName : string/bytes
File or directory for which to retrieve information
In the usual case, the name is limited to MAX_PATH characters. To extend this
limit to nearly 32,000 wide characters, call this and prepend r"\\?\\" to the path.InfoLevelId=GetFileExInfoStandard : int
An integer that gives the set of attribute information to obtain.
See the Win32 SDK documentation for more information.
Transaction=None : PyHANDLE
Handle to a transaction (optional). See win32transaction::CreateTransaction.
If this parameter is specified, GetFileAttributesTransacted will be called (requires Vista or later).
Comments
Not all file systems can record creation and last access time and not all file systems record
them in the same manner. For example, on Windows NT FAT, create time has a resolution of
10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution
of 1 day (really, the access date). On NTFS, access time has a resolution of 1 hour.
Furthermore, FAT records times on disk in local time, while NTFS records times on disk in UTC,
so it is not affected by changes in time zone or daylight saving time.
Accepts keyword arguments.
If bytes are passed for the filename, the ANSI Windows functions are called.
InfoLevelId
|
Information returned
|
|
|
GetFileExInfoStandard | Tuple representing a WIN32_FILE_ATTRIBUTE_DATA struc |
Win32 API References
Search for GetFileAttributesEx at msdn, google or google groups.
Search for GetFileAttributesTransacted at msdn, google or google groups.
Return Value
The result is a tuple of:
Items
- [0] int : attributes
- File Attributes. A combination of the win32com.FILE_ATTRIBUTE_* flags.
- [1] PyDateTime : creationTime
- Specifies when the file or directory was created.
- [2] PyDateTime : lastAccessTime
- For a file, specifies when the file was last read from
or written to. For a directory, the structure specifies when the directory was created. For
both files and directories, the specified date will be correct, but the time of day will
always be set to midnight.
- [3] PyDateTime : lastWriteTime
- For a file, the structure specifies when the file was last
written to. For a directory, the structure specifies when the directory was created.
- [4] int/long : fileSize
- The size of the file. This member has no meaning for directories.