Skip to content

Commit

Permalink
Make GetGettextBinaryPath() helper public
Browse files Browse the repository at this point in the history
  • Loading branch information
vslavik committed Jun 27, 2024
1 parent 54c8b36 commit 7fa854d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 41 deletions.
68 changes: 27 additions & 41 deletions src/gexecute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,44 +46,6 @@
namespace
{

#ifdef __WXOSX__
wxString GetGettextPluginPath()
{
return wxStandardPaths::Get().GetPluginsDir() + "/GettextTools.bundle";
}
#endif // __WXOSX__

#if defined(__WXOSX__) || defined(__WXMSW__)

inline wxString GetAuxBinariesDir()
{
return GetGettextPackagePath() + "/bin";
}

wxString GetPathToAuxBinary(const wxString& program)
{
wxFileName path;
path.SetPath(GetAuxBinariesDir());
path.SetName(program);
#ifdef __WXMSW__
path.SetExt("exe");
#endif
if ( path.IsFileExecutable() )
{
return wxString::Format(_T("\"%s\""), path.GetFullPath().c_str());
}
else
{
wxLogTrace("poedit.execute",
L"%s doesn’t exist, falling back to %s",
path.GetFullPath().c_str(),
program.c_str());
return program;
}
}
#endif // __WXOSX__ || __WXMSW__


struct CommandInvocation
{
CommandInvocation(const wxString& command, const wxString& arguments) : exe(command), args(arguments)
Expand All @@ -99,7 +61,7 @@ struct CommandInvocation
wxString cmdline() const
{
#if defined(__WXOSX__) || defined(__WXMSW__)
const auto fullexe = GetPathToAuxBinary(exe);
const auto fullexe = "\"" + GetGettextBinaryPath(exe) + "\"";
#else
const auto& fullexe(exe);
#endif
Expand Down Expand Up @@ -355,13 +317,37 @@ wxString QuoteCmdlineArg(const wxString& s)


#if defined(__WXOSX__) || defined(__WXMSW__)

wxString GetGettextPackagePath()
{
#if defined(__WXOSX__)
return GetGettextPluginPath() + "/Contents/MacOS";
auto plugin = wxStandardPaths::Get().GetPluginsDir() + "/GettextTools.bundle";
return plugin + "/Contents/MacOS";
#elif defined(__WXMSW__)
return wxStandardPaths::Get().GetDataDir() + wxFILE_SEP_PATH + "GettextTools";
#endif
}
#endif // __WXOSX__ || __WXMSW__

wxString GetGettextBinaryPath(const wxString& program)
{
wxFileName path;
path.SetPath(GetGettextPackagePath() + "/bin");
path.SetName(program);
#ifdef __WXMSW__
path.SetExt("exe");
#endif
if ( path.IsFileExecutable() )
{
return path.GetFullPath();
}
else
{
wxLogTrace("poedit.execute",
L"%s doesn’t exist, falling back to %s",
path.GetFullPath().c_str(),
program.c_str());
return program;
}
}

#endif // __WXOSX__ || __WXMSW__
3 changes: 3 additions & 0 deletions src/gexecute.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ extern bool ExecuteGettextAndParseOutput(const wxString& cmdline,

extern wxString QuoteCmdlineArg(const wxString& s);

#if defined(__WXOSX__) || defined(__WXMSW__)
extern wxString GetGettextPackagePath();
extern wxString GetGettextBinaryPath(const wxString& program);
#endif

#endif // _GEXECUTE_H_

0 comments on commit 7fa854d

Please sign in to comment.