diff --git a/twander.py b/twander.py index bd3efdc..b448817 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ PROGNAME = "twander" -RCSID = "$Id: twander.py,v 1.76 2002/11/23 10:07:27 tundra Exp $" +RCSID = "$Id: twander.py,v 1.77 2002/11/23 10:35:44 tundra Exp $" VERSION = RCSID.split()[2] @@ -150,19 +150,18 @@ REFRESHINT = 5000 # Interval (ms) for automatic refresh -# Stat-related constants (in octal) +# Stat-related -ST_PIPE = 0010000 # FIFO -ST_CHAR = 0020000 # Character Special -ST_DIR = 0040000 # Directory -ST_BLOCK = 0060000 # Block Special -ST_REG = 0100000 # Regular File -ST_SYMLINK = 0120000 # Symbolic Link -ST_SOCKET = 0140000 # Socket +# Permissions lookup ST_PERMIT = ["---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"] - + +# Special file type lookup + +ST_SPECIALS = {"01":"p", "02":"c", "04":"d", "06":"b", + "10":"-", "12":"l", "14":"s"} + ##### # General Literals @@ -918,15 +917,24 @@ detlist.append("") # Mode - 1st get into octal string + mode = stinfo[0] modestr = str("%o" % mode) + # Pad with leading 0s to make 7-digits long + + while len(modestr) < 6: + modestr = "0" + modestr + # Set the permission bits mode = "" for x in [-3, -2, -1]: mode += ST_PERMIT[int(modestr[x])] + # Pickup the special file types + mode = ST_SPECIALS.get(modestr[0:2], "?") + mode + detlist[index] += str(mode) + (11 - len(str(mode))) * " " # Number of links to entry