Add wxStandardPaths::GetSharedLibrariesDir()

This function returns the directory with the application's shared
libraries, which is different from the plugins directory under Mac.

Closes #24052.
This commit is contained in:
oneeyeman1 2024-01-27 12:43:34 -06:00 committed by Vadim Zeitlin
parent f82ccc1a19
commit 91de9867ee
10 changed files with 47 additions and 1 deletions

View file

@ -27,6 +27,7 @@ public:
virtual wxString GetUserDataDir() const override;
virtual wxString GetUserLocalDataDir() const override;
virtual wxString GetPluginsDir() const override;
virtual wxString GetSharedLibrariesDir() const override;
virtual wxString GetUserDir(Dir userDir) const override;
virtual wxString MakeConfigFileName(const wxString& basename,
ConfigFileConv conv = ConfigFileConv_Ext

View file

@ -27,6 +27,7 @@ public:
virtual wxString GetLocalDataDir() const override;
virtual wxString GetUserDataDir() const override;
virtual wxString GetPluginsDir() const override;
virtual wxString GetSharedLibrariesDir() const override;
virtual wxString GetResourcesDir() const override;
virtual wxString
GetLocalizedResourcesDir(const wxString& lang,

View file

@ -129,6 +129,9 @@ public:
// Contents/Plugins app bundle subdirectory under Mac
virtual wxString GetPluginsDir() const = 0;
// return the directory where the shared libraries live
virtual wxString GetSharedLibrariesDir() const;
// get resources directory: resources are auxiliary files used by the
// application and include things like image and sound files
//
@ -252,6 +255,7 @@ public:
virtual wxString GetLocalDataDir() const { return m_prefix; }
virtual wxString GetUserDataDir() const { return m_prefix; }
virtual wxString GetPluginsDir() const { return m_prefix; }
virtual wxString GetSharedLibrariesDir() const override { return m_prefix; }
virtual wxString GetUserDir(Dir WXUNUSED(userDir)) const { return m_prefix; }
virtual wxString
MakeConfigFileName(const wxString& basename,

View file

@ -45,6 +45,7 @@ public:
virtual wxString GetPluginsDir() const override;
virtual wxString GetLocalizedResourcesDir(const wxString& lang,
ResourceCat category) const override;
virtual wxString GetSharedLibrariesDir() const override;
#ifndef __VMS
virtual wxString GetUserDir(Dir userDir) const override;
#endif

View file

@ -312,7 +312,7 @@ public:
/**
Return the program installation prefix, e.g.\ @c /usr, @c /opt or @c /home/zeitlin.
If the prefix had been previously by SetInstallPrefix(), returns that
If the prefix had been previously set by SetInstallPrefix(), returns that
value, otherwise tries to determine it automatically (Linux only right now)
and finally returns the default @c /usr/local value if it failed.
@ -441,6 +441,22 @@ public:
*/
virtual wxString GetUserLocalDataDir() const;
/**
Return OS specific directory where project shared liraries are.
The function does the same thing as GetPluginsDir() under non-Mac platforms
but differs from it under Mac, where plugins (shared libraries loaded by the
application dynamically while it's running) and shared libraries (that the
application is statically linked with) are stored in different directories.
- Windows: returns the folder where the application binary is located
- Unix: returns the libraries installation path, i.e. /usr/lib
- Mac: returns `Contents/Frameworks` bundle subdirectory
@since 3.3.0
*/
virtual wxString GetSharedLibrariesDir() const;
/**
MSW-specific function to customize application directory detection.

View file

@ -171,3 +171,7 @@ wxString wxStandardPathsBase::AppendAppInfo(const wxString& dir) const
return subdir;
}
wxString wxStandardPathsBase::GetSharedLibrariesDir() const
{
return {};
}

View file

@ -348,6 +348,12 @@ wxStandardPaths::MakeConfigFileName(const wxString& basename,
return fn.GetFullName();
}
wxString wxStandardPaths::GetSharedLibrariesDir() const
{
wxFileName fn( GetExecutablePath() );
return fn.GetPath();
}
// ============================================================================
// wxStandardPathsWin16 implementation
// ============================================================================

View file

@ -145,4 +145,11 @@ wxStandardPaths::MakeConfigFileName(const wxString& basename,
return fn.GetFullName();
}
wxString wxStandardPaths::GetSharedLibrariesDir() const
{
// Shared libraries on OSX should be stored inside the
// <Bundle.app>/Contents/Frameworks
return wxCFStringRef::AsString([NSBundle mainBundle].privateFrameworksPath);
}
#endif // wxUSE_STDPATHS

View file

@ -369,4 +369,9 @@ wxStandardPaths::MakeConfigFileName(const wxString& basename,
return fn.GetFullName();
}
wxString wxStandardPaths::GetSharedLibrariesDir() const
{
return GetInstallPrefix() + "/lib";
}
#endif // wxUSE_STDPATHS

View file

@ -403,6 +403,7 @@ void InteractiveOutputTestCase::TestStandardPaths()
wxPrintf(wxT("Executable path:\t%s\n"), stdp.GetExecutablePath());
wxPrintf(wxT("Plugins dir:\t\t%s\n"), stdp.GetPluginsDir());
wxPrintf(wxT("Resources dir:\t\t%s\n"), stdp.GetResourcesDir());
wxPrintf( "Shared Libraries dir:\t\t%s\n", stdp.GetSharedLibrariesDir() );
wxPrintf(wxT("Localized res. dir:\t%s\n"),
stdp.GetLocalizedResourcesDir(wxT("fr")));
wxPrintf(wxT("Message catalogs dir:\t%s\n"),