The full path is written into the .fls file generated by the -recorder option with TeXLive (MikTeX should have a similar option, maybe --recorder).
This files seems to be flushed every line while written, so that it is possible to read the paths of all files accessed so far in the current compiler run.
I wrote the following code to search for a INPUT <path><jobname>.tex line in the .fls file. It also read the first PWD <parent directory> line which is used if the jobname is local. This was actually the easy part and should cover 99.99% of all cases. I just added the remaining parsing code to allow of situations like pdflatex /direct/path/to/document.tex. This should cover usages of -output-directory as well.
I might add this code in my currfile package.
\documentclass{article}
\makeatletter
\def\thepwd@default{./}
\let\thepwd\thepwd@default
\let\theabspath\@empty
\newcommand\getabspath{%
\begingroup
\edef\filename{\jobname.tex}%
\@onelevel@sanitize\filename%
\let\thepwd\thepwd@default
\let\theabspath\@empty
\IfFileExists{\jobname.fls}{%
\openin\@inputcheck=\jobname.fls\relax
\endlinechar\m@ne
\readline\@inputcheck to \line
\expandafter\getabspath@extr\line\relax\relax\relax\relax\relax
\expandafter\getabspath@defs\expandafter{\filename}%
\loop
\readline\@inputcheck to \line
\@onelevel@sanitize\line
\expandafter\getabspath@path\expandafter{\line}%
\ifeof\@inputcheck
\let\iterate\relax
\fi
\ifx\theabspath\@empty
\repeat
\closein\@inputcheck
}{%
\PackageWarning{getabspath}
{The required recorder file (.fls) was not found.\MessageBreak
Please compile with the '-recorder' option.\MessageBreak
Occurred}%
}%
\ifx\theabspath\@empty
\let\theabspath\thepwd
\fi
\edef\@tempa{%
\def\noexpand\thepwd{\thepwd}%
\def\noexpand\theabspath{\theabspath}%
}%
\expandafter
\endgroup
\@tempa
}
\def\getabspath@extr#1#2#3#4#5\relax{%
\edef\@tempa{\detokenize{#1#2#3}}%
\edef\@tempb{\detokenize{PWD}}%
\ifx\@tempa\@tempb
\edef\thepwd{\detokenize{#4#5/}}%
\fi
}
\begingroup
\catcode`I=12
\catcode`N=12
\catcode`P=12
\catcode`U=12
\catcode`T=12
\gdef\getabspath@defs#1{%
\def\getabspath@@path ##1INPUT ##2#1\relax##3\relax##4\@nnil{%
\ifx\@empty##4\@empty\else
\def\theabspath{##2}%
\fi
}%
\def\getabspath@path##1{%
\getabspath@@path##1\relax INPUT \@empty#1\relax{}\relax\@nnil
}%
}
\endgroup
\makeatother
\getabspath
\message{Absolute path: \theabspath^^J}
\message{PWD: \thepwd^^J}
\begin{document}
This file has the absolute path \texttt{\theabspath\jobname.tex}.
PWD: \texttt{\thepwd}
\end{document}
Update 2011/05/05:
I now made this functionality part of my currfile package. It is provided as sub-package currfile-abspath which can also be used on its own. It provides \getmainfile, \getabspath{<file>} and \getpwd which set \themainfile, \theabspath and \thepwd to the main file name (which might be different than \jobname.tex), the absolute path of the given file and the parent working directory of the compiler run.
This new version of currfile is now released as v0.6 2011/05/06.
\jobname). You will need to call some external tool which is operation system depending from within your LaTeX document. – Martin Scharrer♦ Jan 26 '12 at 22:48logfile? I see there the full path of the file (on the 4th line). – digital-Ink Jan 27 '12 at 0:05logfile exists, and when it does, reads the text file as verbatim and outputs the 4th line. Are there such commands available in TeX? – digital-Ink Jan 27 '12 at 10:31\IfFileExistsand\readline, but I wouldn't take it for granted that it is always in the fourth line. – Martin Scharrer♦ Jan 27 '12 at 10:54