]> git.lyx.org Git - lyx.git/blobdiff - src/support/Path.cpp
Don't allow newline characters in document settings.
[lyx.git] / src / support / Path.cpp
index 147efd07e512bafde1dd1d3ac69e95378d0eb6ed..36837f6f9a06e2f530c0316f3f93db18d38813cc 100644 (file)
@@ -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 <config.h>
 
-// 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,9 +23,9 @@ PathChanger::PathChanger(FileName const & path)
        : popped_(false)
 {
        if (!path.empty()) {
-               pushedDir_ = getcwd();
+               pushedDir_ = FileName::getcwd();
 
-               if (pushedDir_.empty() || chdir(path)) {
+               if (pushedDir_.empty() || !path.chdir()) {
                        /* FIXME: throw */
                }
        } else {
@@ -52,7 +49,7 @@ int PathChanger::pop()
                return 0;
        }
 
-       if (chdir(pushedDir_)) {
+       if (!pushedDir_.chdir()) {
                // should throw an exception
                // throw DirChangeError();
        }
@@ -63,3 +60,33 @@ int PathChanger::pop()
 
 } // namespace support
 } // namespace lyx
+
+
+#define PathChanger(x) unnamed_PathChanger;
+
+#ifdef __APPLE__
+
+#include <CoreServices/CoreServices.h>
+
+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.