一个文件可以通过不同的路径访问。例如,
- subpath/myfile.tex
- ./subpath/myfile.tex
- ../current path/subpath/myfile.tex,
- /d/.../current path/subpath/myfile.tex
它们引用myfile.tex
当前路径下的同一个文件。
鉴于这些不同的路径,我如何制作宏来检查它们是否是同一个文件?
例子:
\documentclass{article}
\newcommand\ifsamefile[4]{
% if file #1 is in file-list #2(which is a comma list)
% then do #3
% else do #4
}
\begin{document}
\ifsamefile{myfile}{./myfile.tex,file2.tex}{true}{false} %should be true
\ifsamefile{myfile}{../current path/myfile.tex,file2.tex}{true}{false} %should be true
\issamefile{subpath/file1.tex}{./subpath/file1.tex,subpath/file2.tex}{true}{false} %should be true
\issamefile{subpath/file1.tex}{/d/mypath/current path/subpath/file1.tex,./subpath/file1.tex}{true}{false} %should be true
\end{document}