Writing a de-psfagger
karl at freefriends.org
Thu Jan 23 20:22:09 CET 2020
can I assume all full-path files are system files?
1) run kpsewhich -var-brace-value TEXMF; the output will be a long line
that looks like:
2) Split it on [:;] to get the individual directories. (They'll be
separated by ; on Windows, if you need to support that.)
3) For each directory, remove a leading "!!" string if present.
4) In the -recorder output, if the file is under one of these
directories (begins with that as a prefix), consider it a system
file. If not, not.
5) I can imagine that files under TEXMFHOME may or may not be considered
"system files", depending on the scenario. You'd have to separately look
for the TEXMFHOME value (kpsewhich -var-value TEXMFHOME) and do what's
6) Ditto for the "TEXMFAUXTREES" (usually empty).
kpsewhich -var-brace-value TEXMFAUXTREES
6) It is technically possible for this to get messed up, e.g., if one of
the purportedly "system" trees is defined to be a document directory
(e.g., TEXMFHOME=.). I doubt it'll be a problem in practice, though.
I think there can be no 100% reliable way to determine if an input file
is a "system" file, because there is no definition of "system" at the
file lookup level. It's just a list of directories.
Hope this helps,
P.S. Of course Perl has plenty of ways to distinguish absolute
vs. relative pathnames, e.g., Cwd::abs_path, but I'm guessing you
are already well aware.
More information about the texhax