This makes it possible to use file patterns to detect the rootpath. (cherry picked from commit 2239a2aa)