dircheck.dtx

Alan Jeffrey

1994/05/13

This file defines a command \testdistribution{⟨filename⟩}{⟨error⟩}{⟨help⟩}, which reads a file, and checks that all the filenames listed in it can be read by TEX. It should be run after dircheck.dtx has defined \input@path.

\IfFileExists A version of the \IfFileExists macro which does no fancy searching, and we assume the directory is on the \openin path.

1 ⟨∗testdist⟩

 2 \def\IfFileExists#1{%
 3  \openin\@inputcheck#1 %
 4  \ifeof\@inputcheck
 5  \closein\@inputcheck
 6  \expandafter\@secondoftwo
 7  \else
 8  \closein\@inputcheck
 9  \expandafter\@firstoftwo
10  \fi

11 }

\testdistribution \@filemustexist \@filemustexist@ \@missingfiles  \testdistribution inputs a file of filenames and checks that all the files can be

read by TEX. The files should be separated by whitespace, and terminated by

\endinput.
12 \def\@filemustexist#1{
13 \ifx#1\endinput
14  \expandafter\endinput
15 \else
16  \expandafter\@filemustexist@\expandafter#1%
17 \fi

18 }

19 \def\@filemustexist@#1 {
20 \IfFileExists{#1}{
21  \wlog{Passed `#1'.}
22 }{
23  \wlog{Failed `#1'.}
24  \xdef\@missingfiles{\@missingfiles\message{#1}}

25 }

26 \@filemustexist

27 }

28 \def\testdistribution#1#2#3{
29 \global\let\@missingfiles=\@empty

30 {

31  \catcode`\^^M=\the\catcode`\ \relax
32  \expandafter\@filemustexist\@@input #1

33 }

34 \ifx\@missingfiles\@empty
35 \else
36  \immediate\write16{}
37  \immediate\write16{The following files are missing:}
38  \immediate\write16{}
39  \@missingfiles
40  \immediate\write16{}
41  \errhelp{#3}
42  \errmessage{#2}
43  \immediate\write16{}
44  \immediate\write16{Carrying on with fingers crossed...}
45  \immediate\write16{}
46 \fi

47 } 48 ⟨/testdist⟩