@@ -185,4 +185,52 @@ namespace toucan
185185 out.w = std::any_cast<double >(any[3 ]);
186186 }
187187 }
188+
189+ std::vector<std::filesystem::path> getOpenFXPluginPaths (
190+ const std::filesystem::path& executablePath)
191+ {
192+ const std::filesystem::path parentPath = executablePath.parent_path ();
193+ std::vector<std::filesystem::path> searchPath;
194+
195+ // Add executable directory and relative paths
196+ searchPath.push_back (parentPath);
197+ #if defined(_WINDOWS)
198+ searchPath.push_back (parentPath / " .." / " .." / " .." );
199+ // Add standard Windows OpenFX plugin path
200+ searchPath.push_back (" C:\\ Program Files\\ Common Files\\ OFX\\ Plugins" );
201+ #else // _WINDOWS
202+ searchPath.push_back (parentPath / " .." / " .." );
203+ #if defined(__APPLE__)
204+ // Add standard macOS OpenFX plugin path
205+ searchPath.push_back (" /Library/OFX/Plugins" );
206+ #else
207+ // Add standard Linux/Unix OpenFX plugin path
208+ searchPath.push_back (" /usr/OFX/Plugins" );
209+ #endif // __APPLE__
210+ #endif // _WINDOWS
211+
212+ // Add paths from environment variable OFX_PLUGIN_PATH if it exists
213+ if (const char * envPath = std::getenv (" OFX_PLUGIN_PATH" )) {
214+ #if defined(_WINDOWS)
215+ const char delimiter = ' ;' ;
216+ #else
217+ const char delimiter = ' :' ;
218+ #endif
219+ std::string envPathStr (envPath);
220+ size_t pos = 0 ;
221+ std::string token;
222+ while ((pos = envPathStr.find (delimiter)) != std::string::npos) {
223+ token = envPathStr.substr (0 , pos);
224+ if (!token.empty ()) {
225+ searchPath.push_back (token);
226+ }
227+ envPathStr.erase (0 , pos + 1 );
228+ }
229+ if (!envPathStr.empty ()) {
230+ searchPath.push_back (envPathStr);
231+ }
232+ }
233+
234+ return searchPath;
235+ }
188236}
0 commit comments