re[2]: [suse-programming-e] Detecting File System type
Thanks, That does exactly what I want. Greg
This only works in Linux. I know little of Windows, unfortunately:
- --------cut---------- import os, stat
def getFSType(filename): """ Returns the fstype of the volume containg 'filename', which should be the full path to the file """ # Build dict of filesystems and use the device number as the key devices = {} f = open('/proc/mounts') for line in f.readlines(): info = line.split() devnum = os.stat(info[1])[stat.ST_DEV] devices[devnum] = info[2] f.close()
# Find out which one contains 'filename' and return the fstype return devices[os.stat(filename)[stat.ST_DEV]] - ------------cut---------
If you want to know more about how that works, check out the documentation for the 'stat' module.
- -- James Oakley Engineering - SolutionInc Ltd. joakley@solutioninc.com http://www.solutioninc.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE+cNss+FOexA3koIgRAsC+AJ9NNUm54b0Mt8jmXXGo9kUSdUcCDQCgt7Lm 1d+V3Qagr3fYS2yGp5yCeR8= =1PmL -----END PGP SIGNATURE-----
-- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists/archive/suse-programming-e
participants (1)
-
Greg Freemyer