Generallatex: -output-directory affects input paths for \open?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
fomin
Posts: 10
Joined: Thu Jun 17, 2010 10:52 am

latex: -output-directory affects input paths for \open?

Post by fomin »

Hello all.

I have to check existence of file on given path.

Please, consider small example.

Two files:
dummy.tex (empty)
main.tex

main.tex:

Code: Select all

\documentclass{article}

\makeatletter
\def\IsFileExists#1{%   Simple macro to check file existence
  \openin\@inputcheck#1 %
  \ifeof\@inputcheck
     \message{File #1 -- not exists. 
     }
  \else
     \message{File #1 -- exists. 
     }
  \fi
  \closein\@inputcheck}
\makeatother

\begin{document}
\IsFileExists{dummy.tex}      
\IsFileExists{../dummy.tex}   
\IsFileExists{../../dummy.tex} 
\end{document}


If we run

Code: Select all

latex main.tex  
all OK, we have

Code: Select all

File dummy.tex -- exists.  File ../dummy.tex -- not exists. 
File ../../dummy.tex -- not exists.  (./main.aux) ) 
But if we run (for example, to hide all crap)

Code: Select all

latex -output-directory="subdir" main.tex
we have

Code: Select all

File dummy.tex -- exists.  ***** File ../dummy.tex -- exists. ***** WTF???? 
File ../../dummy.tex -- not exists.  (subdir/main.aux) ) 
Is it a bug or a feature?

How can I do robust check of file existence, not depending from "-output-directory" parameter?

Thanks all in advance,
Sincerely, Stas Fomin

P.S. I use Windows TexLive distrib. Sample files attached.
Attachments
sample-latex-output-directory.zip
(3.07 KiB) Downloaded 118 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply