32#include <wx/filename.h>
37namespace fs = std::filesystem;
46 fs::path file = work /
"model.txt";
47 std::ofstream( file.string() ) <<
"dummy";
51 wxString absFile = wxString::FromUTF8( file.string() );
52 wxString resolved = resolver.
ResolvePath( absFile, wxEmptyString, {} );
53 wxFileName fn( absFile );
54 fn.Normalize( wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS );
57 wxString working = wxString::FromUTF8( work.string() );
58 wxString relResolved = resolver.
ResolvePath( wxS(
"model.txt" ), working, {} );
66 fs::path file = tempDir.
Path() /
"a.txt";
67 std::ofstream( file.string() ) <<
"dummy";
74 std::vector<SEARCH_PATH> paths = { sp };
78 wxString resolved = resolver.
ResolvePath( wxS(
"ALIAS:a.txt" ), wxEmptyString, {} );
82 wxString resolvedLeadingColon = resolver.
ResolvePath( wxS(
":ALIAS:a.txt" ), wxEmptyString, {} );
86 wxString missing = resolver.
ResolvePath( wxS(
"MISSING:a.txt" ), wxEmptyString, {} );
87 BOOST_CHECK( missing.IsEmpty() );
95 fs::path file = tempDir.
Path() /
"sub" /
"model.wrl";
96 fs::create_directories( file.parent_path() );
97 std::ofstream( file.string() ) <<
"dummy";
106 wxString full = wxString::FromUTF8( file.string() );
110 BOOST_CHECK( shortened.StartsWith( wxS(
"${MYLIB}/" ) ) );
113 wxString resolvedBack = resolver.
ResolvePath( shortened, wxEmptyString, {} );
114 wxFileName fn( full );
115 fn.Normalize( wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS );
125 fs::path file = tempDir.
Path() /
"model.wrl";
126 std::ofstream( file.string() ) <<
"dummy";
136 wxString resolved = resolver.
ResolvePath( wxS(
":MYLIB:model.wrl" ), wxEmptyString, {} );
137 wxFileName fn( wxString::FromUTF8( file.string() ) );
138 fn.Normalize( wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS );
151 fs::path file = sub /
"f.txt";
152 std::ofstream( file.string() ) <<
"dummy";
159 BOOST_CHECK_EQUAL( rel, wxString::FromUTF8( ( fs::path(
"sub" ) /
"f.txt" ).
string() ) );
162 fs::path outside = outsideDir.
Path() /
"outside.txt";
163 std::ofstream( outside.string() ) <<
"dummy";
Provide an extensible class to resolve 3D model paths.
wxString ResolvePath(const wxString &aFileName, const wxString &aWorkingPath, std::vector< const EMBEDDED_FILES * > aEmbeddedFilesStack)
Determine the full path of the given file name.
bool UpdatePathList(const std::vector< SEARCH_PATH > &aPathList)
Clear the current path list and substitutes the given path list and update the path configuration fil...
wxString ShortenPath(const wxString &aFullPathName)
Produce a relative path based on the existing search directories or returns the same path if the path...
wxString PathStr() const
Get the path to the temporary directory as a wxString.
const std::filesystem::path & Path() const
Get the path to the temporary directory as a std::filesystem::path.
std::filesystem::path CreateChildDir(const wxString &aName) const
Create and return the path to a direct child directory.
Look for files in a number of paths.
void AddPaths(const wxString &aPaths, int aIndex=-1)
Insert or append path(s).
wxString FilenameWithRelativePathInSearchList(const wxString &aFullFilename, const wxString &aBaseDir)
Return the shortest possible path which can be use later to find a full path from this SEARCH_STACK.
wxString m_Pathvar
Base path as stored in the configuration file.
wxString m_Alias
Alias to the base path.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(ResolveAbsoluteAndWorkingPath)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")