X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FPath.cpp;h=36837f6f9a06e2f530c0316f3f93db18d38813cc;hb=c48091f33a773732fa6c789927e5833e44108d9d;hp=8b85471c979dd93f2726f37d4fa37c55293236ba;hpb=63d19999ebd5ba5c8a7d9e25a2d58c8f990cff1c;p=lyx.git diff --git a/src/support/Path.cpp b/src/support/Path.cpp index 8b85471c97..36837f6f9a 100644 --- a/src/support/Path.cpp +++ b/src/support/Path.cpp @@ -3,20 +3,17 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * * Full author contact details are available in file CREDITS. */ #include -// Needed to prevent the definition of the unnamed_PathChanger macro -// in the header file. - -#define PATHCHANGER_C - #include "support/Path.h" -#include "support/lyxlib.h" + +// undef PathChanger macro when building PathChanger +#undef PathChanger namespace lyx { @@ -26,7 +23,7 @@ PathChanger::PathChanger(FileName const & path) : popped_(false) { if (!path.empty()) { - pushedDir_ = getcwd(); + pushedDir_ = FileName::getcwd(); if (pushedDir_.empty() || !path.chdir()) { /* FIXME: throw */ @@ -63,3 +60,33 @@ int PathChanger::pop() } // namespace support } // namespace lyx + + +#define PathChanger(x) unnamed_PathChanger; + +#ifdef __APPLE__ + +#include + +int getPrivateFrameworkPathName(char * buf, unsigned len, char const * framework) +{ + // Get our application's main bundle from Core Foundation + CFBundleRef myAppsBundle = CFBundleGetMainBundle(); + int result = 0 ; + if (NULL != myAppsBundle) { + CFURLRef baseURL = CFBundleCopyPrivateFrameworksURL( myAppsBundle ); + if (NULL != baseURL) { + CFURLRef bundleURL = CFURLCreateCopyAppendingPathComponent( kCFAllocatorSystemDefault, baseURL, + CFStringCreateWithCString( kCFAllocatorSystemDefault, framework, CFStringGetSystemEncoding() ), + false ); + if (NULL != bundleURL) { + result = CFURLGetFileSystemRepresentation( bundleURL, TRUE, (UInt8*)buf, len ); + } + } + } + return result; +} + +#endif + +// in merged builds this is not the last line.