diff options
author | Karl Berry <karl@freefriends.org> | 2012-05-07 22:49:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-05-07 22:49:57 +0000 |
commit | 6dec32fb82f9e57953655c2dbddb68c5120c4322 (patch) | |
tree | 3d61735f257c8afab559b631f9401aded3a5fa24 /Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty | |
parent | 00594439f07c4918772b72ae22786fb762b93f37 (diff) |
currfile (7may12)
git-svn-id: svn://tug.org/texlive/trunk@26244 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty b/Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty new file mode 100644 index 00000000000..f598d5d6ccb --- /dev/null +++ b/Master/texmf-dist/tex/latex/currfile/currfile-abspath.sty @@ -0,0 +1,171 @@ +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{currfile-abspath}[% + 2012/05/06 + v0.6 + Provides absolute file paths, the parent working directory and the main file name] +\newcommand*\thepwd{} +\newcommand*\theabspath{} +\newcommand*\theabsdir{} +\newcommand*\themainfile{} +\newif\ifcurrfile@abspath@windows +\providecommand\currfile@mainext{tex} +\ifx\currfile@mainext\@empty + \PackageError{currfile-abspath} + {Empty main file extension is not supported}{}% +\fi +\def\currfile@abspath@noflswarning{% + \PackageWarning{currfile-abspath} + {The required recorder file (.fls) was not found.\MessageBreak + Please compile with the '-recorder' option.\MessageBreak + Note that MikTeX requires two compiler runs.\MessageBreak + Occurred}% + \global\let\currfile@abspath@noflswarning\relax + \global\csname currfile@abspathfalse\endcsname +}% +\newcommand\getpwd{% + \begingroup + \let\thepwd\@empty + \IfFileExists{\jobname.fls}{% + \openin\@inputcheck=\jobname.fls\relax + \endlinechar\m@ne + \loop + \readline\@inputcheck to \line + \@onelevel@sanitize\line + \expandafter\currfile@checkpwd\line\relax\relax\relax\relax\relax + \ifeof\@inputcheck\else + \repeat + \closein\@inputcheck + } + \currfile@abspath@noflswarning + \edef\@tempa{% + \def\noexpand\thepwd{\thepwd}% + }% + \expandafter + \endgroup + \@tempa +} +\def\currfile@checkpwd#1#2#3#4#5\relax{% + \edef\@tempa{#1#2#3}% + \edef\@tempb{PWD}% + \@onelevel@sanitize\@tempb + \ifx\@tempa\@tempb + \edef\thepwd{#4#5/}% + \def\@tempa{#4}% + \def\@tempb{/}% + \ifx\@tempa\@tempb + \currfile@abspath@windowsfalse + \else + \currfile@abspath@windowstrue + \fi + \let\iterate\relax + \fi +} +\newcommand\getabspath[1]{% + \begingroup + \edef\filename{#1}% + \@onelevel@sanitize\filename% + \let\theabspath\@empty + \let\theabsdir\@empty + \IfFileExists{\filename}{% + \IfFileExists{\jobname.fls}{% + \openin\@inputcheck=\jobname.fls\relax + \endlinechar\m@ne + \expandafter\currfile@abspath@defs\expandafter{\filename}% + \readline\@inputcheck to \line + \@onelevel@sanitize\line + \expandafter\currfile@checkpwd\line\relax\relax\relax\relax\relax + \loop + \readline\@inputcheck to \line + \@onelevel@sanitize\line + \expandafter\currfile@abspath@getabspath\expandafter{\line}% + \ifeof\@inputcheck\else + \repeat + \closein\@inputcheck + }\currfile@abspath@noflswarning + }{}% + \edef\@tempa{% + \def\noexpand\theabspath{\theabspath}% + \def\noexpand\theabsdir{\theabsdir}% + \def\noexpand\thepwd{\thepwd}% + }% + \expandafter + \endgroup + \@tempa +} +\newcommand\getmainfile{% + \begingroup + \let\themainfile\@empty + \IfFileExists{\jobname.fls}{% + \openin\@inputcheck=\jobname.fls\relax + \endlinechar\m@ne + \readline\@inputcheck to \line + \@onelevel@sanitize\line + \expandafter\currfile@checkpwd\line\relax\relax\relax\relax\relax + \loop + \readline\@inputcheck to \line + \@onelevel@sanitize\line + \expandafter\currfile@abspath@getmainfile\expandafter{\line}% + \ifeof\@inputcheck\else + \repeat + \closein\@inputcheck + }% + \currfile@abspath@noflswarning + \edef\@tempa{% + \def\noexpand\themainfile{\themainfile}% + \def\noexpand\thepwd{\thepwd}% + }% + \expandafter + \endgroup + \@tempa +} +\def\currfile@abspath@testfname#1#2#3\relax{% + \ifcurrfile@abspath@windows + \def\@tempa{#2}% + \def\@tempb{:}% + \else + \def\@tempa{#1}% + \def\@tempb{/}% + \fi + \ifx\@tempa\@tempb\else + \let\theabsdir\thepwd + \fi +} +\begingroup +\catcode`I=12 +\catcode`N=12 +\catcode`P=12 +\catcode`U=12 +\catcode`T=12 +\gdef\currfile@abspath@defs#1{% + \def\currfile@abspath@checkabspath ##1INPUT ##2#1\relax##3\relax##4\@nnil{% + \ifx\@empty##4\@empty\else + \def\theabsdir{##2}% + \ifx\theabsdir\@empty + \currfile@abspath@testfname#1\@empty\@empty\relax + \fi + \edef\theabspath{\theabsdir#1}% + \let\iterate\relax + \fi + }% + \def\currfile@abspath@getabspath##1{% + \currfile@abspath@checkabspath##1\relax INPUT \@empty#1\relax{}\relax\@nnil + }% +} +\def\@tempa#1{% + \gdef\currfile@abspath@checkmainfile ##1INPUT ##2#1\relax##3\relax##4\@nnil{% + \ifx\@empty##4\@empty\else + \def\themainfile{##2#1}% + \let\iterate\relax + \fi + }% + \gdef\currfile@abspath@getmainfile##1{% + \currfile@abspath@checkmainfile##1\relax INPUT \@empty#1\relax{}\relax\@nnil + }% +} +\edef\@tempb{.\currfile@mainext} +\@onelevel@sanitize\@tempb +\expandafter\@tempa\expandafter{\@tempb} +\endgroup +\endinput +%% +%% End of file `currfile-abspath.sty'. |