changeset 352:b256ae4f4bc8

treesum: implement the "filetypes" command to show all the filetype indicators that are used in digest output
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 01 Apr 2025 20:38:06 +0200
parents 3e29b3e648d3
children 6994ed768db5
files cutils/treesum.py cutils/util/walk.py
diffstat 2 files changed, 81 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cutils/treesum.py	Tue Apr 01 20:15:03 2025 +0200
+++ b/cutils/treesum.py	Tue Apr 01 20:38:06 2025 +0200
@@ -268,6 +268,13 @@
                     "is listed below:",
         metavar="COMMAND")
 
+    markerparser = subparsers.add_parser(
+        "filetypes",
+        help="Show the filetype indicators for all sorts of files",
+        description=walk.HELP_FILETYPE_INDICATORS,
+        formatter_class=argparse.RawDescriptionHelpFormatter,
+        add_help=False)
+
     genparser = subparsers.add_parser(
         "generate",
         help="Generate checksums for directory trees",
@@ -334,12 +341,17 @@
                 hparser.print_help()
             elif opts.help_command == "patterns":
                 patparser.print_help()
+            elif opts.help_command == "filetypes":
+                markerparser.print_help()
             else:
                 parser.print_help()
         return 0
     elif opts.subcommand == "patterns":
         patparser.print_help()
         return 0
+    elif opts.subcommand == "filetypes":
+        markerparser.print_help()
+        return 0
 
     # Reparse strictly
     opts = parser.parse_args(args=argv)
--- a/cutils/util/walk.py	Tue Apr 01 20:15:03 2025 +0200
+++ b/cutils/util/walk.py	Tue Apr 01 20:38:06 2025 +0200
@@ -28,6 +28,75 @@
 from . import PY2
 
 
+HELP_FILETYPE_INDICATORS = r"""
+FILETYPE INDICATORS
+===================
+
+File and directory paths are printed using names analogous to calling
+"ls -F/--classify". The indicator strings (aka "marker" or "tags") are
+appended to their names as follows.
+
+Some standard indicators are:
+
+  /
+    denotes a directory
+
+  /./@/
+    denotes a symbolic link to a directory
+
+  /./@
+    Classifies a symlink to a regular filesystem object (i.e. a regular file).
+    The target objects are not classified as directories or other special
+    filesystem objects.
+    Also used if a symbolic link is broken and the target type cannot
+    determined.
+
+  /./| --- /./@|
+    FIFO --- symlink to FIFO
+
+  /./= --- /./@=
+    Socket --- symlink to socket
+
+  /./> --- /./@>
+    Door -- symlink to door.
+
+    Solaris.
+
+  /./% --- /./@%
+    Whiteout --- symlink to whiteout.
+
+    Typically Used by union filesystems) (BSD).
+
+More non-standard indicators are:
+
+  /./: --- /./@:
+    Character special device --- symlink to character special device
+
+  /./; --- /./@;
+    Block special device --- symlink to block special device
+
+  /./+ --- /./@+
+    Event port --- symlink to event port.
+
+    Solaris, Illumos.
+
+In an aggregated (directory) checksum at the end of a block the following
+indicators are used:
+
+  ./@/
+    Symbolic link to a directory
+
+  ./@
+    Symbolic link to other filesystem object.
+
+    Also used if the link is broken and the target type cannot determined.
+
+NOTE: Executable files have no special indicator here. The "ls -F" command
+      would use the `*' character in this case.
+
+"""
+
+
 _notset = object()
 
 _logger = logging.getLogger(__name__)