Variable: tramp-perl-directory-files-and-attributes

tramp-perl-directory-files-and-attributes is a variable defined in tramp-sh.el.gz.

Value

"%p -e '\nchdir($ARGV[0]) or printf(\"\\\"Cannot change to $ARGV[0]: $''!''\\\"\\n\"), exit();\nopendir(DIR,\".\") or printf(\"\\\"Cannot open directory $ARGV[0]: $''!''\\\"\\n\"), exit();\n@list = readdir(DIR);\nclosedir(DIR);\n$n = scalar(@list);\nprintf(\"(\\n\");\nfor($i = 0; $i < $n; $i++)\n{\n    $filename = $list[$i];\n    @stat = lstat($filename);\n    if (($stat[2] & 0170000) == 0120000)\n    {\n        $type = readlink($filename);\n        $type =~ s/\"/\\\\\"/g;\n        $type = \"\\\"$type\\\"\";\n    }\n    elsif (($stat[2] & 0170000) == 040000)\n    {\n        $type = \"t\";\n    }\n    else\n    {\n        $type = \"nil\"\n    };\n    $filename =~ s/\"/\\\\\"/g;\n    printf(\n        \"(\\\"%%s\\\" %%s %%u (%%s . %%u) (%%s . %%u) (%%u %%u) (%%u %%u) (%%u %%u) %%u %%u t %%u -1)\\n\",\n        $filename,\n        $type,\n        $stat[3],\n        \"\\\"\" . getpwuid($stat[4]) . \"\\\"\",\n        $stat[4],\n        \"\\\"\" . getgrgid($stat[5]) . \"\\\"\",\n        $stat[5],\n        $stat[8] >> 16 & 0xffff,\n        $stat[8] & 0xffff,\n        $stat[9] >> 16 & 0xffff,\n        $stat[9] & 0xffff,\n        $stat[10] >> 16 & 0xffff,\n        $stat[10] & 0xffff,\n        $stat[7],\n        $stat[2],\n        $stat[1]);\n}\nprintf(\")\\n\");' \"$1\" %n"

Documentation

Perl script implementing directory-files-and-attributes as Lisp readable output. Format specifiers are replaced by tramp-expand-script, percent characters need to be doubled.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
(defconst tramp-perl-directory-files-and-attributes "\
%p -e '
chdir($ARGV[0]) or printf(\"\\\"Cannot change to $ARGV[0]: $''!''\\\"\\n\"), exit();
opendir(DIR,\".\") or printf(\"\\\"Cannot open directory $ARGV[0]: $''!''\\\"\\n\"), exit();
@list = readdir(DIR);
closedir(DIR);
$n = scalar(@list);
printf(\"(\\n\");
for($i = 0; $i < $n; $i++)
{
    $filename = $list[$i];
    @stat = lstat($filename);
    if (($stat[2] & 0170000) == 0120000)
    {
        $type = readlink($filename);
        $type =~ s/\"/\\\\\"/g;
        $type = \"\\\"$type\\\"\";
    }
    elsif (($stat[2] & 0170000) == 040000)
    {
        $type = \"t\";
    }
    else
    {
        $type = \"nil\"
    };
    $filename =~ s/\"/\\\\\"/g;
    printf(
        \"(\\\"%%s\\\" %%s %%u (%%s . %%u) (%%s . %%u) (%%u %%u) (%%u %%u) (%%u %%u) %%u %%u t %%u -1)\\n\",
        $filename,
        $type,
        $stat[3],
        \"\\\"\" . getpwuid($stat[4]) . \"\\\"\",
        $stat[4],
        \"\\\"\" . getgrgid($stat[5]) . \"\\\"\",
        $stat[5],
        $stat[8] >> 16 & 0xffff,
        $stat[8] & 0xffff,
        $stat[9] >> 16 & 0xffff,
        $stat[9] & 0xffff,
        $stat[10] >> 16 & 0xffff,
        $stat[10] & 0xffff,
        $stat[7],
        $stat[2],
        $stat[1]);
}
printf(\")\\n\");' \"$1\" %n"
  "Perl script implementing `directory-files-and-attributes' as Lisp `read'able
output.
Format specifiers are replaced by `tramp-expand-script', percent
characters need to be doubled.")