# Read file without file extension from hidden directory

I'm trying to read some data from a file and use the following approach:

\documentclass{minimal}
\newcommand{\file}{./.dir/.testFile}
\begin{document}
\loop
\data
\repeat
\end{document}


This works for the following files (specified in the \file macro):

• testFile.txt --> Normal file
• dir/testFile.txt --> Normal file in folder
• .dir/testFile.txt --> Normal file in hidden folder
• .dir/.testFile --> Hidden file in hidden folder

But exactly the case which I need is not working: .dir/testFile. Why is it not possible to read a file without file extension and is there a way to get around this? Renaming the file is no option for me as the file is used/modified/created by another application. I need just the first line of the file, if this simplifies the problem in any way.

According to this question/answer, the extension .tex is always appended to the file name if no extension is given (even by using low-level commands). But I still think there must be a way to bypass this.

System:

• pdfTeX, Version 3.1415926-2.4.1.40.13
• MiKTeX 2.9 (Revision 2.9.4533, 32 bit)
• Windows 7 Professional (64 bit)
• That's weird: I've just try your example, it works fine. I create dir /tmp/.dir, move there file .testFile with some text and move your latex file into \tmp. It compiles. Maybe your problem is with access to that file? – Eddy_Em Aug 15 '13 at 7:17
• Now try the same with the file named testFile (no extension, not hidden). This is the case which is not working. – jrast Aug 15 '13 at 7:23
• It works in all cases. – Eddy_Em Aug 15 '13 at 7:58
• OK, this sounds MiKTeX-specific: I tested with my TeX Live 2013 system, Windows 7 (64-bit), pdfTeX 3.1415926-2.5-1.40.14 and all was fine. Perhaps you could add your Windows version to the question, and specify 32- or 64-bit MiKTeX (just in case this is relevant). – Joseph Wright Aug 15 '13 at 8:39
• for input at least it was supposed to be fixed some years ago: sourceforge.net/p/miktex/bugs/1248 – David Carlisle Aug 15 '13 at 10:51

I don't have MiKTeX to test but it seems that extensionless files for input was fixed with this bug.

If \read wasn't fixed at the same time, the workaround should probably work: append a . to the end of the filename in the TeX call:

\newcommand{\file}{./.dir/testFile.}
%

• Ok, this seems to solve the Problem and @karlkoeller has explained very well what goes on behind the scene in MiKTex. Before i accept this as answer: How portable is this solution? Will it work with TexLive on Linux for example? – jrast Aug 15 '13 at 20:59
• @jrast don't think it is portable testfile and testfile. are unrelated filenames on *ix filesystems. Also I think it's a Miktex bug, prior to the latex2e release it was common for tex implementations to use different search algorithms for \input and \read but we put some effort into getting everyone to use the same so that \openin could be used to test if a file exists so \InputIfFileExists (and \input{}) do the right thing. – David Carlisle Aug 15 '13 at 21:06

The problem arises, if you are using LuaTeX.

The source of the problem is that TeX tries the extension .tex for file names without extensions. Thus it seems that LuaTeX forces the extensions .tex if no extension is given. (A bug-report could be made.)

However, LuaTeX also supports an alternative syntax for specifying file names, similar to \pdfximage, the file name can be surrounded by braces, then the correct file is found:

\documentclass{minimal}
\newcommand{\file}{./.dir/testFile}
\begin{document}