#endif
#if defined (USE_MACOSX_PACKAGING)
-# include <CoreServices/CoreServices.h> // FSFindFolder, FSRefMakePath
+# include "support/qstring_helpers.h"
+# include <QDir>
+# include <QDesktopServices>
#endif
using namespace std;
Package const & package()
{
- LASSERT(initialised_, /**/);
+ LAPPERR(initialised_);
return package_;
}
system_support_dir_ =
get_system_support_dir(abs_binary,
command_line_system_support_dir);
- }
+ }
// Find the LyX executable
lyx_binary_ = findLyxBinary(abs_binary);
FileName const configure_script(addName(system_support().absFileName(), "configure.py"));
configure_command_ = os::python() + ' ' +
quoteName(configure_script.toFilesystemEncoding(), quote_python) +
- with_version_suffix();
+ with_version_suffix() + " --binary-dir=" + binary_dir().absFileName();
LYXERR(Debug::INIT, "<package>\n"
<< "\tbinary_dir " << binary_dir().absFileName() << '\n'
{
#if defined (USE_WINDOWS_PACKAGING)
static FileName const home_dir(getEnv("USERPROFILE"));
+#elif defined (USE_MACOSX_PACKAGING)
+ static FileName const home_dir(fromqstr(QDir::homePath()));
#else // Posix-like.
static FileName const home_dir(getEnv("HOME"));
#endif
FileName findLyxBinary(FileName const & abs_binary)
{
string ext;
- if (!abs_binary.extension().empty()) {
+ string checkname = abs_binary.toFilesystemEncoding();
+ int check_len = checkname.length();
+ int prgsuffixlen = string(PROGRAM_SUFFIX).length();
+ if ((prgsuffixlen > 0) && (check_len > prgsuffixlen) &&
+ (checkname.substr(check_len-prgsuffixlen) == string(PROGRAM_SUFFIX))) {
+ ext = "";
+ }
+ else if (!abs_binary.extension().empty()) {
ext = "." + abs_binary.extension();
}
(void)home_dir; // Silence warning about unused variable.
os::GetFolderPath win32_folder_path;
return FileName(win32_folder_path(os::GetFolderPath::PERSONAL));
+#elif defined (USE_MACOSX_PACKAGING) && (QT_VERSION >= 0x050000)
+ (void)home_dir; // Silence warning about unused variable.
+ return FileName(fromqstr(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)));
+#elif defined (USE_MACOSX_PACKAGING)
+ (void)home_dir; // Silence warning about unused variable.
+ return FileName(fromqstr(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)));
#else // Posix-like.
return home_dir;
#endif
os::GetFolderPath win32_folder_path;
return FileName(addPath(win32_folder_path(os::GetFolderPath::APPDATA), PACKAGE));
-#elif defined (USE_MACOSX_PACKAGING)
+#elif defined (USE_MACOSX_PACKAGING) && (QT_VERSION >= 0x050000)
(void)home_dir; // Silence warning about unused variable.
+ return FileName(addPath(fromqstr(QStandardPaths::writableLocation(QStandardPaths::DataLocation)), PACKAGE));
- FSRef fsref;
- OSErr const error_code =
- FSFindFolder(kUserDomain, kApplicationSupportFolderType,
- kDontCreateFolder, &fsref);
- if (error_code != 0)
- return FileName();
-
- // FSRefMakePath returns the result in utf8
- char store[PATH_MAX + 1];
- OSStatus const status_code =
- FSRefMakePath(&fsref,
- reinterpret_cast<UInt8*>(store), PATH_MAX);
- if (status_code != 0)
- return FileName();
-
- return FileName(addPath(reinterpret_cast<char const *>(store), PACKAGE));
+#elif defined (USE_MACOSX_PACKAGING)
+ (void)home_dir; // Silence warning about unused variable.
+ return FileName(addPath(fromqstr(QDesktopServices::storageLocation(QDesktopServices::DataLocation)), PACKAGE));
#else // USE_POSIX_PACKAGING
return FileName(addPath(home_dir.absFileName(), string(".") + PACKAGE));