diff --git a/tdir b/tdir index 1e40ff0..af00e65 100755 --- a/tdir +++ b/tdir @@ -12,7 +12,7 @@ # Version info -VERSION = "$Id: tdir,v 1.67 2002/09/02 00:40:36 tundra Exp $" +VERSION = "$Id: tdir,v 1.68 2006/05/10 18:33:04 tundra Exp $" # Booleans @@ -29,13 +29,15 @@ PAD = " " # Padding character SEP = "." # Filename "extension" separator TRUNC = "^" # Character indicating name truncation +DOTFILE = '.' # Dotfiles start with this # Defaults -RECURSE = FALSE # No recursion -SHOWDIR = TRUE # Show directories in listing -SHOWFILE = TRUE # Show files in listing -SORTBYEXT = TRUE # Sort file names by extension +RECURSE = FALSE # No recursion +SHOWDIR = TRUE # Show directories in listing +SHOWDOT = TRUE # Show dotfiles in listing +SHOWFILE = TRUE # Show files in listing +SORTBYEXT = TRUE # Sort file names by extension def OrderByExtension(list): @@ -114,14 +116,15 @@ DirList = [] FileList = [] for x in files: + df = x.startswith(DOTFILE) # Track whether name is a 'dotfile/dir' if (dir[-1] == '/') or (dir[-1] == '\\'): # This if/else sequence necessary because dirstring = dir + x # 'tdir /' did not properly report directories else: # on WinDoze32 systems which appears to dirstring = dir + "/" + x # handle '//' or '\/' in files names very well. if os.path.isdir(dirstring): - if SHOWDIR: + if SHOWDIR and (not df or SHOWDOT): DirList.append(x) - elif SHOWFILE: + elif SHOWFILE and (not df or SHOWDOT): FileList.append(x) DisplayOutput(dir, DirList, FileList) @@ -131,6 +134,7 @@ ("tdir " + VERSION.split()[2] + " - Copyright (c) 2001, 2002 TundraWare Inc., All Rights Reserved. \n", ""), (" usage: tdir [-Rdefhtv] [-c #] [-s c] [-w #] [dir...] where,\n\n", ""), + ("-D", "Do not display dot files\n"), ("-R", "Recurse down each named directory tree\n"), ("-c #", "Column width\n"), ("-d", "Do not display directories in output\n"), @@ -154,12 +158,14 @@ # Program entry and command line processing try: - opts, args = getopt.getopt(sys.argv[1:], '-Rc:edfhs:tvw:') + opts, args = getopt.getopt(sys.argv[1:], '-DRc:edfhs:tvw:') except getopt.GetoptError: Usage() sys.exit(2) for opt, val in opts: + if opt == "-D": + SHOWDOT = FALSE if opt == "-R": RECURSE = TRUE if opt == "-c":