diff --git a/twander.py b/twander.py index fe2cc69..706f282 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ PROGNAME = "twander" -RCSID = "$Id: twander.py,v 1.79 2002/11/24 19:23:46 tundra Exp $" +RCSID = "$Id: twander.py,v 1.80 2002/11/24 22:46:18 tundra Exp $" VERSION = RCSID.split()[2] @@ -162,6 +162,10 @@ ST_SPECIALS = {"01":"p", "02":"c", "04":"d", "06":"b", "10":"-", "12":"l", "14":"s"} +# String used to separate symlink entry from its real path + +SYMPTR = " -> " + ##### # General Literals @@ -513,7 +517,7 @@ sellist = [] for entry in self.DirList.curselection(): - sellist.append(self.DirList.get(entry)[UI.NameIndex:]) + sellist.append(self.DirList.get(entry)[UI.NameFirst:].split(SYMPTR)[0]) return sellist @@ -527,7 +531,7 @@ def LastInSelection(self): index = self.DirList.curselection() if index: - return self.DirList.get(index[-1])[UI.NameIndex:] + return self.DirList.get(index[-1])[UI.NameFirst:].split(SYMPTR)[0] else: return "" @@ -753,7 +757,7 @@ return # If selection is a directory, move there and list contents. - + if os.path.isdir(os.path.join(UI.CurrentDir, selected)): # If we're on Unix, don't follow symlinks pointing back to themselves @@ -902,7 +906,7 @@ fList.sort() - # For both choices below, we have to set the UI.NameIndex + # For both choices below, we have to set the UI.NameFirst # value. This tells other handlers where in a given # selection the actual name of the file can be found. # This is necessary because we may be selecting a from @@ -915,7 +919,7 @@ # If user has not requested detailed display, we're done if not DETAILVIEW: - UI.NameIndex = 0 + UI.NameFirst = 0 return dList + fList # Detailed display requested, do the work @@ -925,7 +929,10 @@ UI.TotalSize = 0 for index in range(len(all)): try: - stinfo = os.stat(os.path.join(currentdir, all[index])) + fn = os.path.join(currentdir, all[index]) + if fn[-1] == PSEP: + fn =fn[:-1] + stinfo = os.lstat(fn) detlist.append("") # Mode - 1st get into octal string @@ -1001,12 +1008,27 @@ ftime = " ".join(time.ctime(stinfo[9]).split()[1:]) detlist[index] += ftime + (21 - len(ftime)) * " " - # Set the index into the file name - UI.NameIndex = len(detlist[index]) + # Set the index into beginning of file name + UI.NameFirst = len(detlist[index]) # File name + detlist[index] += all[index] + # Include symlink details as necessary + if detlist[index][0] == 'l': + + # If the symlink points to a file + # in the same directory, just show + # the filename and not the whole path + + f = os.path.realpath(currentdir + all[index]) + r = os.path.split(f) + if r[0] == currentdir[:-1]: + f = r[1] + + detlist[index] += SYMPTR + f + except: detlist[index] = all[index]