When a file is attached thanks to \textattachfile{⟨file⟩}{⟨text⟩} provided by attach(2) package, the file open by the link has same content but not same name as ⟨file⟩.
For instance, in the following MWE, I pretend the link will open foo.tex but it will open foo.tex.xxx instead, where xxx is a random string. The file open has the same content as foo.tex but, because of its strange extension, is not open as a .tex file by the underlying text editor.
\begin{filecontents*}{foo.tex}
\documentclass{article}
\begin{document}
Foo.
\end{document}
\end{filecontents*}
%
\documentclass{article}
\usepackage{xcolor}
\usepackage[color=black]{attachfile2}
\begin{document}
\textattachfile{foo.tex}{Link to `foo.tex'}.
\end{document}
Is there a way for a file attached by means of attach/attach2 package to be open with same name?