% \iffalse meta-comment
%
% Copyright 1993-1995 the LaTeX3 project and any individual authors
% listed elsewhere in this file.  All rights reserved.
% 
% For further copyright information see the file legal.txt, and any
% other copyright notices 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.
% 
%   For error reports concerning UNCHANGED versions of this file no more
%   than one year old, see bugs.txt.
% 
%   Please do not request updates from us directly.  Primary
%   distribution is through the CTAN archives.
% 
% 
% IMPORTANT COPYRIGHT NOTICE:
% 
% You are NOT ALLOWED to distribute this file alone.
% 
% You are allowed to distribute this file under the condition that it is
% distributed together with all the files listed in manifest.txt.
% 
% If you receive only some of these files from someone, complain!
% 
% Permission is granted to copy this file to another file with a clearly
% different name and to customize the declarations in that copy to serve
% the needs of your installation, provided that you comply with
% the conditions in the file legal.txt.
% 
% However, NO PERMISSION is granted to produce or to distribute a
% modified version of this file under its original name.
%  
% You are NOT ALLOWED to change this file.
% 
% 
% \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



