Python Basics
Python Advanced
Python Useful References
Python Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
Python os.fstat() Method
Description:
This method returns information about a file associated with the fd. Here is the structure returned by fstat method:
st_dev: ID of device containing file
st_ino: inode number
st_mode: protection
st_nlink: number of hard links
st_uid: user ID of owner
st_gid: group ID of owner
st_rdev: device ID (if special file)
st_size: total size, in bytes
st_blksize: blocksize for filesystem I/O
st_blocks: number of blocks allocated
st_atime: time of last access
st_mtime: time of last modification
st_ctime: time of last status change
Syntax:
Parameters:
Here is the detail of parameters:
Example:
#!/usr/bin/python
import os, sys
# Open a file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )
# Now get the touple
info = os.fstat(fd)
print "File Info :", info
# Now get uid of the file
print "UID of the file :%d" % info.st_uid
# Now get gid of the file
print "GID of the file :%d" % info.st_gid
# Close opened file
os.close( fd)
|
This would produce following result:
File Info : (33261, 3753776L, 103L, 1, 0, 0,
102L, 1238783197, 1238786767, 1238786767)
UID of the file :0
GID of the file :0
|
|
|
|