% \iffalse meta-comment
%
% Copyright 1994 the LaTeX3 project and the individual authors.
% All rights reserved. For further copyright information see the file
% legal.txt, and any other copyright indicated in this file.
% 
% This file is part of the LaTeX2e system.
% ----------------------------------------
% 
%  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 bugs.txt.
% 
% 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 manifest.txt.
% 
% 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
%
% \ProvidesFile{testdist.dtx}[1994/05/13 Testing distribution]
%
% \iffalse
%%% File: testdist.dtx
%
%<*unstripped>
\ifx\documentclass\undefined\let\next\relax\else\def\next{%
%</unstripped>
%<*driver>
% \fi
\ProvidesFile{testdist.dtx}[1994/05/13 Testing distribution]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{testdist.dtx}
\title{dircheck.dtx}
\author{Alan Jeffrey}
\date{\filedate}
\begin{document}
 \maketitle
 \DocInput{\filename}
\end{document}
%</driver>
%<*unstripped>
}\fi\next
%</unstripped>
% \fi
%
% \changes{v0.02}{1993/12/20}{This file now defines a command
%    \cs{testdistribution}, which reads an arbitrary file, rather than
%    only reading manifest.l2e.}
% \changes{v0.03}{1993/12/21}{Added \cs{@tfor}.}
% \changes{v0.04}{1994/01/18}{Removed directory searching.}
% \changes{v0.05}{1994/01/20}{Corrected missing file number bug.}
% \changes{v0.06}{1994/05/13}{Improved documentation.}
%
% 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|. 
%
% \changes{v0.03}{1993/12/21}{Chris pointed out that we need `@tfor
%    here}
% \changes{v0.04}{1994/01/18}{Removed all the directory searching}
%
% \begin{macro}{\IfFileExists}
%    A version of the |\IfFileExists| macro which does no fancy
%    searching, and we assume the directory is on the |\openin| path. 
% \changes{v0.05}{1994/01/20}{Corrected missing file number bug.}
%    \begin{macrocode}
%<*testdist>
 \def\IfFileExists#1{%
    \openin\@inputcheck#1 %
    \ifeof\@inputcheck
      \closein\@inputcheck
      \expandafter\@secondoftwo
    \else
      \closein\@inputcheck
      \expandafter\@firstoftwo
    \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



