openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.95k stars 2.55k forks source link

defaultDataPath() can't handle junction correctly (on Windows) #6376

Open Anton-V-K opened 5 years ago

Anton-V-K commented 5 years ago

Consider following directories structure:

Project
+-- Debug (contains *.exe)
|    +-- data => Project\data
+-- Release
|    +-- data => Project\data
|
+-- data (contains *.png)

where both Project\Debug\data, and Project\Release\data are "symlinks" (junctions) to Project\data. In such situation it's impossible to load resources (images) from Project\Debug\data or Project\Release\data, because defaultDataPath() builds wrong path. The problem lies in code:

return std::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(),  "data/")).make_preferred().string();

join returns correct path like X:\...\Project\Debug\data/, while boost::filesystem::canonical seems to be trying to expand the path to something like X:\...\Project\Debug\Project\Debug\data, which is completely incorrect. This is a known issue in boost::fs (see https://svn.boost.org/trac10/ticket/10900 and https://svn.boost.org/trac10/ticket/11138), which seems to be fixed at the main branch.

Tested with released version 0.10.1.

dimitre commented 1 year ago

Hello @Anton-V-K can you please check if this issue is still relevant on nightly builds? thank you