% \iffalse meta-comment
%
% Copyright (C) 1993 by LaTeX3 project.  All rights reserved.
% For additional copyright information see further down in this file.
% 
% This file is part of the LaTeX2e system (PRELIMINARY TEST RELEASE)
% ------------------------------------------------------------------
% 
%  This system is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% 
% 
% IMPORTANT NOTICE:
% 
% For error reports in case of UNCHANGED versions see readme files.
% 
% Please do not request updates from us directly.  Distribution is
% done through Mail-Servers and TeX organizations.
% 
% You are not allowed to change this file.
% 
% You are allowed to distribute this file under the condition that
% it is distributed together with all files mentioned in 00readme.l2e.
% 
% If you receive only some of these files from someone, complain!
% 
% You are NOT ALLOWED to distribute this file alone.  You are NOT
% ALLOWED to take money for the distribution or use of either this
% file or a changed version, except for a nominal charge for copying
% etc.
% \fi
%\iffalse
% ====================================================================
%  @LaTeX-distribution-file{
%     author_1        = "Alan Jeffrey",
%     version         = "0.02",
%     date            = "20 December 1993",
%     time            = "14:32:47 GMT",
%     filename        = "testdist.dtx",
%     address_1       = "School of Cognitive and Computing Sciences
%                        University of Sussex
%                        Brighton BN1 9QH
%                        UK",
%     telephone       = "+44 273 606755 x 3238",
%     FAX             = "+44 273 678188",
%     checksum        = "???",
%     email           = "alanje@cogs.sussex.ac.uk",
%     codetable       = "ISO/ASCII",
%     keywords        = "LaTeX, standard file",
%     supported       = "yes",
%     abstract        = "This file checks that all the distribution
%                        files for LaTeX2e are present.",
%  }
% ====================================================================
%\fi
%
% \changes{0.02}{1993/12/20}{This file now defines a command
%    `testdistribution, which reads an arbitrary file, rather than
%    only reading manifest.l2e.}
%
% This file defines a command
% |\testdistribution{|\meta{filename}|}{|\meta{error}|}{|\meta{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|. 
%
% \begin{macro}{\IfFileExists}
%    We copy the |\IfFileExists| macro from |latex.dtx|.
%    \begin{macrocode}
%<*testdist>
\ifx\input@path\@undefined
 \def\IfFileExists#1{%
    \openin\@inputcheck#1 %
    \ifeof\@inputcheck
      \expandafter\@secondoftwo
    \else
      \closein\@inputcheck
      \expandafter\@firstoftwo
    \fi
    }
\else
  \def\IfFileExists#1{%
    \let\@tempa\@secondoftwo
    \expandafter\@tfor\expandafter\@tempb\expandafter
                          :\expandafter=\input@path\do{%
      \openin\@inputcheck\@tempb#1 %
      \ifeof\@inputcheck\else
        \ifx\@tempa\@secondoftwo
          \edef\@filef@und{\@tempb#1 }%
          \let\@tempa\@firstoftwo
        \fi
      \fi
      \closein\@inputcheck}%
    \@tempa}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\testdistribution}
% \begin{macro}{\@filemustexist}
% \begin{macro}{\@filemustexist@}
% \begin{macro}{\@missingfiles}
%    |\testdistribution| inputs a file of filenames and checks to make sure
%    all the files can be read by \TeX.  The files should be separated
%    by whitespace, and terminated by |\endinput|.
%    \begin{macrocode}
\def\@filemustexist#1{
   \ifx#1\endinput
      \expandafter\endinput
   \else
      \expandafter\@filemustexist@\expandafter#1%
   \fi
}
\def\@filemustexist@#1 {
   \IfFileExists{#1}{
      \wlog{Passed `#1'.}
   }{
      \wlog{Failed `#1'.}
      \xdef\@missingfiles{\@missingfiles\message{#1}}
   }
   \@filemustexist
}
\def\testdistribution#1#2#3{
   \global\let\@missingfiles=\@empty
   {
      \catcode`\^^M=\the\catcode`\ \relax
      \expandafter\@filemustexist\@@input #1
   }
   \ifx\@missingfiles\@empty
   \else
      \immediate\write16{}
      \immediate\write16{The following files are missing:} 
      \immediate\write16{}
      \@missingfiles
      \immediate\write16{}
      \errhelp{#3}
      \errmessage{#2}
      \immediate\write16{}
      \immediate\write16{Carrying on with fingers crossed...}
      \immediate\write16{}
   \fi
}
%</testdist>
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
\endinput



