I'm trying to get a project's root folder path for usage later on in the preamble. My latex knowledge is... limited... but I've gotten a solution working using a combination of the currfile, and xstring packages. Unfortunately I don't understand what the * is doing to the functions to make the function work.
My MWE, Example.tex, is located within /Users/Me/Tutorials/Example1/. I get the path to it's root directory using the currfile package and then I use xstring:\StrBefore* to cut out the folders I know exist (/Tutorials/Example1/).
As best I can tell it is an expansion trick of some kind - as I understand it \StrBefore* makes the first argument be correctly expanded and treated with the right character codes. But what exactly does that mean? If it is an expansion issue then why does it work without the * syntax for the \UnExpectedResult string?
Ideally I'd like to be understand how I might have achieved the same result using explicit expansion commands instead. Not because I think it would make things easier, but because the knowledge will certainly come in handy. There are a variety of related posts on this site, but I couldn't find any answers that were approachable to me. This might be due to of a lack of latex vocabulary.
MWE named Example.tex:
\documentclass{minimal}
\usepackage[parents,abspath]{currfile}
\usepackage{xstring}
%%% Get the MWE root location.
\getabspath{Example.tex}
% \theabsdir contains /Users/Me/Tutorials/Example1/
\newcommand{\WithStar}{\StrBefore*{\theabsdir}{Tutorials/}}
\newcommand{\WithoutStar}{\StrBefore{\theabsdir}{Tutorials/}}
%%% Create an example string
\newcommand{\ExampleRoot}{/Users/Me/Tutorials/Example1/Example.tex}
\newcommand{\UnExpectedResult}{\StrBefore{\ExampleRoot}{Tutorials/}}
\begin{document}
MWE:\\
theabspath: \theabspath\\
theabsdir: \theabsdir
WithStar: \WithStar\\
WithoutStar: \WithoutStar\\
UnExpectedResult: \UnExpectedResult
\end{document}

\theabsdironly provides cat codes 10,11, and 12, because right now it is causing me an issue with a folder that has an underscore. Perhaps converting\theabspathback into standard catcode would have produced the same results? – Lagix Feb 06 '20 at 23:20retokenize? – Lagix Feb 10 '20 at 17:17