ToDo: long outstanding patch to allow access to system paths in background mode
authorAndrea Weikert <elubie@gmx.net>
Wed, 5 Jan 2011 14:00:14 +0000 (14:00 +0000)
committerAndrea Weikert <elubie@gmx.net>
Wed, 5 Jan 2011 14:00:14 +0000 (14:00 +0000)
Thanks Damien Plisson for contributing the Carbon and Cocoa implementation

29 files changed:
intern/ghost/CMakeLists.txt
intern/ghost/GHOST_C-api.h
intern/ghost/GHOST_ISystem.h
intern/ghost/GHOST_ISystemPaths.h [new file with mode: 0644]
intern/ghost/GHOST_Path-api.h
intern/ghost/GHOST_Types.h
intern/ghost/SConscript
intern/ghost/intern/GHOST_ISystemPaths.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_Path-api.cpp
intern/ghost/intern/GHOST_System.h
intern/ghost/intern/GHOST_SystemCarbon.cpp
intern/ghost/intern/GHOST_SystemCarbon.h
intern/ghost/intern/GHOST_SystemCocoa.h
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_SystemPaths.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsCarbon.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsCarbon.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsCocoa.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsCocoa.mm [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsWin32.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsWin32.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsX11.cpp [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemPathsX11.h [new file with mode: 0644]
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/intern/GHOST_SystemWin32.h
intern/ghost/intern/GHOST_SystemX11.cpp
intern/ghost/intern/GHOST_SystemX11.h
intern/ghost/intern/Makefile
source/blender/windowmanager/intern/wm_init_exit.c

index 7a14709..7c2a2dd 100644 (file)
@@ -36,10 +36,12 @@ set(SRC
        intern/GHOST_Buttons.cpp
        intern/GHOST_CallbackEventConsumer.cpp
        intern/GHOST_C-api.cpp
+       intern/GHOST_Path-api.cpp
        intern/GHOST_DisplayManager.cpp
        intern/GHOST_EventManager.cpp
        intern/GHOST_EventPrinter.cpp
        intern/GHOST_ISystem.cpp
+       intern/GHOST_ISystemPaths.cpp
        intern/GHOST_ModifierKeys.cpp
        intern/GHOST_NDOFManager.cpp
        intern/GHOST_Path-api.cpp
@@ -87,20 +89,24 @@ if(APPLE)
                list(APPEND SRC
                        intern/GHOST_DisplayManagerCocoa.mm
                        intern/GHOST_SystemCocoa.mm
+                       intern/GHOST_SystemPathsCocoa.mm
                        intern/GHOST_WindowCocoa.mm
                        
                        intern/GHOST_DisplayManagerCocoa.h
                        intern/GHOST_SystemCocoa.h
+                       intern/GHOST_SystemPathsCocoa.h
                        intern/GHOST_WindowCocoa.h
                )
        else()
                list(APPEND SRC
                        intern/GHOST_DisplayManagerCarbon.cpp
                        intern/GHOST_SystemCarbon.cpp
+                       intern/GHOST_SystemPathsCarbon.cpp
                        intern/GHOST_WindowCarbon.cpp
 
                        intern/GHOST_DisplayManagerCarbon.h
                        intern/GHOST_SystemCarbon.h
+                       intern/GHOST_SystemPathsCarbon.h
                        intern/GHOST_WindowCarbon.h
                )
        endif()
@@ -115,10 +121,12 @@ elseif(UNIX)
        list(APPEND SRC
                intern/GHOST_DisplayManagerX11.cpp
                intern/GHOST_SystemX11.cpp
+               intern/GHOST_SystemPathsX11.cpp
                intern/GHOST_WindowX11.cpp
 
                intern/GHOST_DisplayManagerX11.h
                intern/GHOST_SystemX11.h
+               intern/GHOST_SystemPathsX11.h
                intern/GHOST_WindowX11.h
        )
 
@@ -134,12 +142,14 @@ elseif(WIN32)
        list(APPEND SRC
                intern/GHOST_DisplayManagerWin32.cpp
                intern/GHOST_SystemWin32.cpp
+               intern/GHOST_SystemPathsWin32.cpp
                intern/GHOST_WindowWin32.cpp
                intern/GHOST_DropTargetWin32.cpp
 
                intern/GHOST_DisplayManagerWin32.h
                intern/GHOST_DropTargetWin32.h
                intern/GHOST_SystemWin32.h
+               intern/GHOST_SystemPathsWin32.h
                intern/GHOST_WindowWin32.h
        )
 endif()
index 8bee4c5..5d531ae 100644 (file)
@@ -46,7 +46,6 @@ extern "C" {
  * In the API the pointer is casted to the actual C++ class.
  * @param      name    Name of the handle to create.
  */
-#define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
 
 GHOST_DECLARE_HANDLE(GHOST_SystemHandle);
 GHOST_DECLARE_HANDLE(GHOST_TimerTaskHandle);
index 227ba44..ec39248 100644 (file)
@@ -370,25 +370,7 @@ public:
         */
        virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
 
-                       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       virtual const GHOST_TUns8* getSystemDir() const = 0;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-       virtual const GHOST_TUns8* getUserDir() const = 0;
-
-       /**
-         * Determine the directory of the current binary
-         * @return Unsigned char string pointing to the binary dir
-         */
-        virtual const GHOST_TUns8* getBinaryDir() const = 0;
+       
 protected:
        /**
         * Initialize the system.
diff --git a/intern/ghost/GHOST_ISystemPaths.h b/intern/ghost/GHOST_ISystemPaths.h
new file mode 100644 (file)
index 0000000..a4bb942
--- /dev/null
@@ -0,0 +1,93 @@
+/**
+ * $Id: $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef _GHOST_ISYSTEMPATHS_H_
+#define _GHOST_ISYSTEMPATHS_H_
+
+#include "GHOST_Types.h"
+
+class GHOST_ISystemPaths
+{
+public:
+       /**
+        * Creates the one and only system.
+        * @return An indication of success.
+        */
+       static GHOST_TSuccess create();
+
+       /**
+        * Disposes the one and only system.
+        * @return An indication of success.
+        */
+       static GHOST_TSuccess dispose();
+
+       /**
+        * Returns a pointer to the one and only system (nil if it hasn't been created).
+        * @return A pointer to the system.
+        */
+       static GHOST_ISystemPaths* get();
+
+protected:
+       /**
+        * Constructor.
+        * Protected default constructor to force use of static createSystem member.
+        */
+       GHOST_ISystemPaths() {}
+
+       /**
+        * Destructor.
+        * Protected default constructor to force use of static dispose member.
+        */
+       virtual ~GHOST_ISystemPaths() {}
+
+public:
+       /**
+        * Determine the base dir in which shared resources are located. It will first try to use
+        * "unpack and run" path, then look for properly installed path, not including versioning.
+        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
+        */
+       virtual const GHOST_TUns8* getSystemDir() const = 0;
+
+       /**
+        * Determine the base dir in which user configuration is stored, not including versioning.
+        * If needed, it will create the base directory.
+        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
+        */
+       virtual const GHOST_TUns8* getUserDir() const = 0;
+
+       /**
+         * Determine the directory of the current binary
+         * @return Unsigned char string pointing to the binary dir
+         */
+        virtual const GHOST_TUns8* getBinaryDir() const = 0;
+
+private:
+       /** The one and only system paths*/
+       static GHOST_ISystemPaths* m_systemPaths;
+};
+
+#endif
index 60b05f5..23a5062 100644 (file)
 extern "C" { 
 #endif
 
+GHOST_DECLARE_HANDLE(GHOST_SystemPathsHandle);
+
+/**
+ * Creates the one and only instance of the system path access.
+ * @return An indication of success.
+ */
+extern GHOST_TSuccess GHOST_CreateSystemPaths(void);
+
+/**
+ * Disposes the one and only system.
+ * @return An indication of success.
+ */
+extern GHOST_TSuccess GHOST_DisposeSystemPaths(void);
+
 /**
  * Determine the base dir in which shared resources are located. It will first try to use
  * "unpack and run" path, then look for properly installed path, not including versioning.
index dd7b052..af17b10 100644 (file)
@@ -33,6 +33,8 @@
 #include "MEM_guardedalloc.h"
 #endif
 
+#define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
+
 typedef        char                            GHOST_TInt8;
 typedef        unsigned char           GHOST_TUns8;
 typedef short                          GHOST_TInt16;
index e6190c5..7aedc08 100644 (file)
@@ -11,7 +11,7 @@ if window_system == 'darwin':
     sources += env.Glob('intern/*.mm')
 
 
-pf = ['GHOST_DisplayManager', 'GHOST_System', 'GHOST_Window', 'GHOST_DropTarget']
+pf = ['GHOST_DisplayManager', 'GHOST_System', 'GHOST_SystemPaths', 'GHOST_Window', 'GHOST_DropTarget']
 defs=['_USE_MATH_DEFINES']
 
 if window_system in ('linux2', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'freebsd9', 'irix6', 'aix4', 'aix5'):
diff --git a/intern/ghost/intern/GHOST_ISystemPaths.cpp b/intern/ghost/intern/GHOST_ISystemPaths.cpp
new file mode 100644 (file)
index 0000000..5241cbb
--- /dev/null
@@ -0,0 +1,104 @@
+/**
+ * $Id: GHOST_ISystem.cpp 28254 2010-04-18 10:28:37Z campbellbarton $
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/**
+
+ * $Id: GHOST_ISystem.cpp 28254 2010-04-18 10:28:37Z campbellbarton $
+ * Copyright (C) 2001 NaN Technologies B.V.
+ * @author     Maarten Gribnau
+ * @date       May 7, 2001
+ */
+
+#include "GHOST_ISystemPaths.h"
+
+#ifdef WIN32
+#      include "GHOST_SystemPathsWin32.h"
+#else
+#      ifdef __APPLE__
+#              ifdef GHOST_COCOA
+#                      include "GHOST_SystemPathsCocoa.h"
+#              else
+#                      include "GHOST_SystemPathsCarbon.h"
+#              endif
+#      else
+#              include "GHOST_SystemPathsX11.h"
+#      endif
+#endif
+
+
+GHOST_ISystemPaths* GHOST_ISystemPaths::m_systemPaths = 0;
+
+
+GHOST_TSuccess GHOST_ISystemPaths::create()
+{
+       GHOST_TSuccess success;
+       if (!m_systemPaths) {
+#ifdef WIN32
+               m_systemPaths = new GHOST_SystemPathsWin32 ();
+#else
+#      ifdef __APPLE__
+#              ifdef GHOST_COCOA
+                       m_systemPaths = new GHOST_SystemPathsCocoa ();
+#              else
+                       m_systemPaths = new GHOST_SystemPathsarbon ();
+#              endif
+#      else 
+               m_systemPaths = new GHOST_SystemPathsX11 ();
+#      endif
+#endif 
+               success = m_systemPaths != 0 ? GHOST_kSuccess : GHOST_kFailure;
+       }
+       else {
+               success = GHOST_kFailure;
+       }
+       return success;
+}
+
+GHOST_TSuccess GHOST_ISystemPaths::dispose()
+{
+       GHOST_TSuccess success = GHOST_kSuccess;
+       if (m_systemPaths) {
+               delete m_systemPaths;
+               m_systemPaths = 0;
+       }
+       else {
+               success = GHOST_kFailure;
+       }
+       return success;
+}
+
+GHOST_ISystemPaths* GHOST_ISystemPaths::get()
+{
+       if (!m_systemPaths) {
+               create();
+       }
+       return m_systemPaths;
+}
+
+
+
index b2b7c68..adb8a7d 100644 (file)
  */
 
 #include "intern/GHOST_Debug.h"
+#include "GHOST_Types.h"
 #include "GHOST_Path-api.h"
-#include "GHOST_ISystem.h"
+#include "GHOST_ISystemPaths.h"
+
+GHOST_TSuccess GHOST_CreateSystemPaths(void)
+{
+       return GHOST_ISystemPaths::create();;
+}
+
+GHOST_TSuccess GHOST_DisposeSystemPaths(void)
+{
+       return GHOST_ISystemPaths::dispose();
+}
 
 const GHOST_TUns8* GHOST_getSystemDir()
 {
-       GHOST_ISystem* system = GHOST_ISystem::getSystem();
-       return system ? system->getSystemDir() : NULL;
+       GHOST_ISystemPaths* systemPaths = GHOST_ISystemPaths::get();
+       return systemPaths ? systemPaths->getSystemDir() : 0;
 }
 
 const GHOST_TUns8* GHOST_getUserDir()
 {
-       GHOST_ISystem* system = GHOST_ISystem::getSystem();
-       return system ? system->getUserDir() : NULL; /* will be NULL in background mode */
+       GHOST_ISystemPaths* systemPaths = GHOST_ISystemPaths::get();
+       return systemPaths ? systemPaths->getUserDir() : 0; /* shouldn't be NULL */
 }
 
 const GHOST_TUns8* GHOST_getBinaryDir()
 {
-       GHOST_ISystem* system = GHOST_ISystem::getSystem();
-       return system ? system->getBinaryDir() : NULL; /* will be NULL in background mode */
+       GHOST_ISystemPaths* systemPaths = GHOST_ISystemPaths::get();
+       return systemPaths ? systemPaths->getBinaryDir() : 0;  /* shouldn't be NULL */
 }
index a186707..d9b9012 100644 (file)
@@ -297,25 +297,7 @@ public:
           */
          virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
 
-               /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       virtual const GHOST_TUns8* getSystemDir() const = 0;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-       virtual const GHOST_TUns8* getUserDir() const = 0;
-
-       /**
-         * Determine the directory of the current binary
-         * @return Unsigned char string pointing to the binary dir
-         */
-        virtual const GHOST_TUns8* getBinaryDir() const = 0;
+       
 protected:
        /**
         * Initialize the system.
index 75cbe5d..0cd11f6 100644 (file)
@@ -1214,39 +1214,3 @@ void GHOST_SystemCarbon::putClipboard(GHOST_TInt8 *buffer, bool selection) const
                CFRelease(textData);
        }
 }
-
-
-const GHOST_TUns8* GHOST_SystemCarbon::getSystemDir() const
-{
-       return (GHOST_TUns8*)"/Library/Application Support";
-}
-
-const GHOST_TUns8* GHOST_SystemCarbon::getUserDir() const
-{
-       static char usrPath[256] = "";
-       char* env = getenv("HOME");
-       
-       if (env) {
-               strncpy(usrPath, env, 245);
-               usrPath[245]=0;
-               strcat(usrPath, "/Library/Application Support");
-               return (GHOST_TUns8*) usrPath;
-       }
-       else
-               return NULL;
-}
-
-const GHOST_TUns8* GHOST_SystemCarbon::getBinaryDir() const
-{
-       CFURLRef bundleURL;
-       CFStringRef pathStr;
-       static char path[256];
-       CFBundleRef mainBundle = CFBundleGetMainBundle();
-       
-       bundleURL = CFBundleCopyBundleURL(mainBundle);
-       pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
-       CFStringGetCString(pathStr, path, 255, kCFStringEncodingASCII);
-       CFRelease(pathStr);
-       CFRelease(bundleURL);
-       return (GHOST_TUns8*)path;
-}
index 723652d..fd5c61f 100644 (file)
@@ -190,27 +190,6 @@ public:
         */
        virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
 
-       
-       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       virtual const GHOST_TUns8* getSystemDir() const;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-       virtual const GHOST_TUns8* getUserDir() const;
-
-       /**
-         * Determine the directory of the current binary
-         * @return Unsigned char string pointing to the binary dir
-         */
-        virtual const GHOST_TUns8* getBinaryDir() const;
-
 protected:
        /**
         * Initializes the system.
index 3ae8ec0..ffc9a6b 100644 (file)
@@ -213,26 +213,6 @@ public:
         */
        virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
 
-       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       virtual const GHOST_TUns8* getSystemDir() const;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-       virtual const GHOST_TUns8* getUserDir() const;
-
-       /**
-         * Determine the directory of the current binary
-         * @return Unsigned char string pointing to the binary dir
-         */
-        virtual const GHOST_TUns8* getBinaryDir() const;
-
        /**
      * Handles a window event. Called by GHOST_WindowCocoa window delegate
      * @param eventType The type of window event
index 80356c1..08d8356 100644 (file)
@@ -1796,67 +1796,3 @@ void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const
        [pool drain];
 }
 
-#pragma mark Base directories retrieval
-
-const GHOST_TUns8* GHOST_SystemCocoa::getSystemDir() const
-{
-       static GHOST_TUns8 tempPath[512] = "";
-       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-       NSString *basePath;
-       NSArray *paths;
-       
-       paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES);
-       
-       if ([paths count] > 0)
-               basePath = [paths objectAtIndex:0];
-       else { 
-               [pool drain];
-               return NULL;
-       }
-       
-       strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
-       
-       [pool drain];
-       return tempPath;
-}
-
-const GHOST_TUns8* GHOST_SystemCocoa::getUserDir() const
-{
-       static GHOST_TUns8 tempPath[512] = "";
-       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-       NSString *basePath;
-       NSArray *paths;
-
-       paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
-
-       if ([paths count] > 0)
-               basePath = [paths objectAtIndex:0];
-       else { 
-               [pool drain];
-               return NULL;
-       }
-
-       strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
-       
-       [pool drain];
-       return tempPath;
-}
-
-const GHOST_TUns8* GHOST_SystemCocoa::getBinaryDir() const
-{
-       static GHOST_TUns8 tempPath[512] = "";
-       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-       NSString *basePath;
-       
-       basePath = [[NSBundle mainBundle] bundlePath];
-       
-       if (basePath == nil) {
-               [pool drain];
-               return NULL;
-       }
-       
-       strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);
-       
-       [pool drain];
-       return tempPath;
-}
diff --git a/intern/ghost/intern/GHOST_SystemPaths.h b/intern/ghost/intern/GHOST_SystemPaths.h
new file mode 100644 (file)
index 0000000..526a39e
--- /dev/null
@@ -0,0 +1,74 @@
+/**
+ * $Id: $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef _GHOST_SYSTEMPATHS_H_
+#define _GHOST_SYSTEMPATHS_H_
+
+#include "GHOST_ISystemPaths.h"
+
+class GHOST_SystemPaths : public GHOST_ISystemPaths
+{
+protected:
+       /**
+        * Constructor.
+        * Protected default constructor to force use of static createSystem member.
+        */
+       GHOST_SystemPaths(){};
+
+       /**
+        * Destructor.
+        * Protected default constructor to force use of static dispose member.
+        */
+       virtual ~GHOST_SystemPaths(){};
+
+public:
+
+       /**
+        * Determine the base dir in which shared resources are located. It will first try to use
+        * "unpack and run" path, then look for properly installed path, not including versioning.
+        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
+        */
+       virtual const GHOST_TUns8* getSystemDir() const = 0;
+
+    /**
+         * Determine the base dir in which user configuration is stored, not including versioning.
+         * If needed, it will create the base directory.
+         * @return Unsigned char string pointing to user dir (eg ~/.blender/).
+         */
+       virtual const GHOST_TUns8* getUserDir() const = 0;
+
+       /**
+         * Determine the directory of the current binary
+         * @return Unsigned char string pointing to the binary dir
+         */
+        virtual const GHOST_TUns8* getBinaryDir() const = 0;
+
+};
+
+#endif
+
+
diff --git a/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp b/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp
new file mode 100644 (file)
index 0000000..d35ab6e
--- /dev/null
@@ -0,0 +1,78 @@
+/**
+ * $Id: $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Damien Plisson 2010
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <Carbon/Carbon.h>
+#include <ApplicationServices/ApplicationServices.h>
+#include "GHOST_SystemPathsCarbon.h"
+
+
+/***/
+
+GHOST_SystemPathsCarbon::GHOST_SystemPathsCarbon() 
+{
+}
+
+GHOST_SystemPathsCarbon::~GHOST_SystemPathsCarbon()
+{
+}
+
+const GHOST_TUns8* GHOST_SystemPathsCarbon::getSystemDir() const
+{
+       return (GHOST_TUns8*)"/Library/Application Support";
+}
+
+const GHOST_TUns8* GHOST_SystemPathsCarbon::getUserDir() const
+{
+       static char usrPath[256] = "";
+       char* env = getenv("HOME");
+       
+       if (env) {
+               strncpy(usrPath, env, 245);
+               usrPath[245]=0;
+               strcat(usrPath, "/Library/Application Support");
+               return (GHOST_TUns8*) usrPath;
+       }
+       else
+               return NULL;
+}
+
+const GHOST_TUns8* GHOST_SystemPathsCarbon::getBinaryDir() const
+{
+       CFURLRef bundleURL;
+       CFStringRef pathStr;
+       static char path[256];
+       CFBundleRef mainBundle = CFBundleGetMainBundle();
+       
+       bundleURL = CFBundleCopyBundleURL(mainBundle);
+       pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
+       CFStringGetCString(pathStr, path, 255, kCFStringEncodingASCII);
+       CFRelease(pathStr);
+       CFRelease(bundleURL);
+       return (GHOST_TUns8*)path;
+}
+
diff --git a/intern/ghost/intern/GHOST_SystemPathsCarbon.h b/intern/ghost/intern/GHOST_SystemPathsCarbon.h
new file mode 100644 (file)
index 0000000..f50e66a
--- /dev/null
@@ -0,0 +1,83 @@
+/**
+ * $Id: $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2010 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Damien Plisson 2010
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef _GHOST_SYSTEM_PATHS_CARBON_H_
+#define _GHOST_SYSTEM_PATHS_CARBON_H_
+
+#ifndef __APPLE__
+#error Apple OSX only!
+#endif // __APPLE__
+
+#include <Carbon/Carbon.h>
+
+#include "GHOST_SystemPaths.h"
+
+/**
+ * OSX/Carbon Implementation of GHOST_SystemPaths class.
+ * @see GHOST_System.
+ * @author     Andrea Weikert
+ * @date       Aug 1, 2010
+ */
+class GHOST_SystemPathsCarbon : public GHOST_SystemPaths {
+public:
+    /**
+     * Constructor.
+     */
+    GHOST_SystemPathsCarbon();
+    
+    /** 
+     * Destructor.
+     */
+    ~GHOST_SystemPathsCarbon();
+    
+       /**
+        * Determine the base dir in which shared resources are located. It will first try to use
+        * "unpack and run" path, then look for properly installed path, not including versioning.
+        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
+        */
+       virtual const GHOST_TUns8* getSystemDir() const;
+
+       /**
+        * Determine the base dir in which user configuration is stored, not including versioning.
+        * If needed, it will create the base directory.
+        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
+        */
+       virtual const GHOST_TUns8* getUserDir() const;
+
+       /**
+         * Determine the directory of the current binary
+         * @return Unsigned char string pointing to the binary dir
+         */
+        virtual const GHOST_TUns8* getBinaryDir() const;
+
+};
+
+#endif // _GHOST_SYSTEM_CARBON_H_
+
+
+
diff --git a/intern/ghost/intern/GHOST_SystemPathsCocoa.h b/intern/ghost/intern/GHOST_SystemPathsCocoa.h
new file mode 100644 (file)
index 0000000..59909d9
--- /dev/null
@@ -0,0 +1,75 @@
+/**
+ * $Id: $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2010 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Damien Plisson 2010
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef _GHOST_SYSTEM_PATHS_COCOA_H_
+#define _GHOST_SYSTEM_PATHS_COCOA_H_
+
+#ifndef __APPLE__
+#error Apple OSX only!
+#endif // __APPLE__
+
+
+#include "GHOST_SystemPaths.h"
+
+
+class GHOST_SystemPathsCocoa : public GHOST_SystemPaths {
+public:
+    /**
+     * Constructor.
+     */
+    GHOST_SystemPathsCocoa();
+    
+    /** 
+     * Destructor.
+     */
+    ~GHOST_SystemPathsCocoa();
+
+       /**
+        * Determine the base dir in which shared resources are located. It will first try to use
+        * "unpack and run" path, then look for properly installed path, not including versioning.
+        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
+        */
+       virtual const GHOST_TUns8* getSystemDir() const;
+
+       /**
+        * Determine the base dir in which user configuration is stored, not including versioning.
+        * If needed, it will create the base directory.
+        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
+        */
+       virtual const GHOST_TUns8* getUserDir() const;
+
+       /**
+         * Determine the directory of the current binary
+         * @return Unsigned char string pointing to the binary dir
+         */
+        virtual const GHOST_TUns8* getBinaryDir() const;
+
+};
+
+#endif // _GHOST_SYSTEM_COCOA_H_
+
diff --git a/intern/ghost/intern/GHOST_SystemPathsCocoa.mm b/intern/ghost/intern/GHOST_SystemPathsCocoa.mm
new file mode 100644 (file)
index 0000000..d12ad6f
--- /dev/null
@@ -0,0 +1,116 @@
+/**\r
+ * $Id: $\r
+ *\r
+ * ***** BEGIN GPL LICENSE BLOCK *****\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version. \r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software Foundation,\r
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+ *\r
+ * The Original Code is Copyright (C) 2010 Blender Foundation.\r
+ * All rights reserved.\r
+ *\r
+ * \r
+ * Contributor(s): Damien Plisson 2010\r
+ *\r
+ * ***** END GPL LICENSE BLOCK *****\r
+ */\r
+\r
+#import <Cocoa/Cocoa.h>\r
+\r
+/*For the currently not ported to Cocoa keyboard layout functions (64bit & 10.6 compatible)*/\r
+#include <Carbon/Carbon.h>\r
+\r
+#include <sys/time.h>\r
+#include <sys/types.h>\r
+#include <sys/sysctl.h>\r
+\r
+#include "GHOST_SystemPathsCocoa.h"\r
+\r
+\r
+#pragma mark initialization/finalization\r
+\r
+\r
+GHOST_SystemPathsCocoa::GHOST_SystemPathsCocoa()\r
+{\r
+}\r
+\r
+GHOST_SystemPathsCocoa::~GHOST_SystemPathsCocoa()\r
+{\r
+}\r
+\r
+\r
+#pragma mark Base directories retrieval\r
+\r
+const GHOST_TUns8* GHOST_SystemPathsCocoa::getSystemDir() const\r
+{\r
+       static GHOST_TUns8 tempPath[512] = "";\r
+       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];\r
+       NSString *basePath;\r
+       NSArray *paths;\r
+       \r
+       paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask, YES);\r
+       \r
+       if ([paths count] > 0)\r
+               basePath = [paths objectAtIndex:0];\r
+       else { \r
+               [pool drain];\r
+               return NULL;\r
+       }\r
+       \r
+       strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);\r
+       \r
+       [pool drain];\r
+       return tempPath;\r
+}\r
+\r
+const GHOST_TUns8* GHOST_SystemPathsCocoa::getUserDir() const\r
+{\r
+       static GHOST_TUns8 tempPath[512] = "";\r
+       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];\r
+       NSString *basePath;\r
+       NSArray *paths;\r
+\r
+       paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);\r
+\r
+       if ([paths count] > 0)\r
+               basePath = [paths objectAtIndex:0];\r
+       else { \r
+               [pool drain];\r
+               return NULL;\r
+       }\r
+\r
+       strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);\r
+       \r
+       [pool drain];\r
+       return tempPath;\r
+}\r
+\r
+const GHOST_TUns8* GHOST_SystemPathsCocoa::getBinaryDir() const\r
+{\r
+       static GHOST_TUns8 tempPath[512] = "";\r
+       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];\r
+       NSString *basePath;\r
+       \r
+       basePath = [[NSBundle mainBundle] bundlePath];\r
+       \r
+       if (basePath == nil) {\r
+               [pool drain];\r
+               return NULL;\r
+       }\r
+       \r
+       strcpy((char*)tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]);\r
+       \r
+       [pool drain];\r
+       return tempPath;\r
+}\r
diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp
new file mode 100644 (file)
index 0000000..9946768
--- /dev/null
@@ -0,0 +1,81 @@
+/**
+ * $Id: GHOST_SystemWin32.cpp 30060 2010-07-06 20:31:55Z elubie $
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2011 Blender Foundation.
+ * All rights reserved.
+ * 
+ * Contributor(s): Blender Foundation
+ *                 Andrea Weikert
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "GHOST_SystemPathsWin32.h"
+
+#define WIN32_LEAN_AND_MEAN
+#ifdef _WIN32_IE
+#undef _WIN32_IE
+#endif
+#define _WIN32_IE 0x0501
+#include <windows.h>
+#include <shlobj.h>
+
+
+GHOST_SystemPathsWin32::GHOST_SystemPathsWin32()
+{
+}
+
+GHOST_SystemPathsWin32::~GHOST_SystemPathsWin32()
+{
+}
+
+const GHOST_TUns8* GHOST_SystemPathsWin32::getSystemDir() const
+{
+       static char knownpath[MAX_PATH];
+       HRESULT hResult = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath);
+
+       if (hResult == S_OK)
+       {
+               return (GHOST_TUns8*)knownpath;
+       }
+
+       return NULL;
+}
+
+const GHOST_TUns8* GHOST_SystemPathsWin32::getUserDir() const
+{
+       static char knownpath[MAX_PATH];
+       HRESULT hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath);
+
+       if (hResult == S_OK)
+       {
+               return (GHOST_TUns8*)knownpath;
+       }
+
+       return NULL;
+}
+
+const GHOST_TUns8* GHOST_SystemPathsWin32::getBinaryDir() const
+{
+       static char fullname[MAX_PATH];
+       if(GetModuleFileName(0, fullname, MAX_PATH)) {
+               return (GHOST_TUns8*)fullname;
+       }
+
+       return NULL;
+}
diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.h b/intern/ghost/intern/GHOST_SystemPathsWin32.h
new file mode 100644 (file)
index 0000000..c4abfbb
--- /dev/null
@@ -0,0 +1,82 @@
+/**
+ * $Id: $
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef _GHOST_SYSTEM_PATHS_WIN32_H_
+#define _GHOST_SYSTEM_PATHS_WIN32_H_
+
+#ifndef WIN32
+#error WIN32 only!
+#endif // WIN32
+
+#include <windows.h>
+
+#include "GHOST_SystemPaths.h"
+
+
+/**
+ * WIN32 Implementation of GHOST_SystemPaths class.
+ * @see GHOST_SystemPaths.
+ * @author     Andrea Weikert
+ * @date       August 1, 2010
+ */
+class GHOST_SystemPathsWin32 : public GHOST_SystemPaths {
+public:
+       /**
+        * Constructor.
+        */
+       GHOST_SystemPathsWin32();
+
+       /**
+        * Destructor.
+        */
+       virtual ~GHOST_SystemPathsWin32();
+
+       /**
+        * Determine the base dir in which shared resources are located. It will first try to use
+        * "unpack and run" path, then look for properly installed path, not including versioning.
+        * @return Unsigned char string pointing to system dir (eg /usr/share/).
+        */
+       const GHOST_TUns8* getSystemDir() const;
+
+       /**
+        * Determine the base dir in which user configuration is stored, not including versioning.
+        * If needed, it will create the base directory.
+        * @return Unsigned char string pointing to user dir (eg ~/).
+        */
+        const GHOST_TUns8* getUserDir() const;
+
+        /**
+         * Determine the directory of the current binary
+         * @return Unsigned char string pointing to the binary dir
+         */
+        const GHOST_TUns8* getBinaryDir() const;
+
+};
+
+#endif // _GHOST_SYSTEM_PATHS_WIN32_H_
+
diff --git a/intern/ghost/intern/GHOST_SystemPathsX11.cpp b/intern/ghost/intern/GHOST_SystemPathsX11.cpp
new file mode 100644 (file)
index 0000000..0f0578f
--- /dev/null
@@ -0,0 +1,76 @@
+/**
+ * $Id: $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2010 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "GHOST_SystemPathsX11.h"
+
+#include "GHOST_Debug.h"
+
+// For timing
+
+#include <sys/time.h>
+#include <unistd.h>
+
+#include <stdio.h> // for fprintf only
+#include <cstdlib> // for exit
+
+#ifndef PREFIX
+#  define PREFIX "/usr/local"
+#endif
+
+
+using namespace std;
+
+GHOST_SystemPathsX11::GHOST_SystemPathsX11()
+{
+}
+
+GHOST_SystemPathsX11::~GHOST_SystemPathsX11()
+{
+}
+
+const GHOST_TUns8* GHOST_SystemPathsX11::getSystemDir() const
+{
+       return (GHOST_TUns8*) PREFIX "/share";
+}
+
+const GHOST_TUns8* GHOST_SystemPathsX11::getUserDir() const
+{
+       char* env = getenv("HOME");
+       if(env) {
+               return (GHOST_TUns8*) env;
+       } else {
+               return NULL;
+       }
+}
+
+const GHOST_TUns8* GHOST_SystemPathsX11::getBinaryDir() const
+{
+       return NULL;
+}
+
+
diff --git a/intern/ghost/intern/GHOST_SystemPathsX11.h b/intern/ghost/intern/GHOST_SystemPathsX11.h
new file mode 100644 (file)
index 0000000..f4b7dda
--- /dev/null
@@ -0,0 +1,73 @@
+/**
+ * $Id: $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2010 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef _GHOST_SYSTEM_PATHS_X11_H_
+#define _GHOST_SYSTEM_PATHS_X11_H_
+
+#include "GHOST_SystemPaths.h"
+#include "../GHOST_Types.h"
+
+
+class GHOST_SystemPathsX11 : public GHOST_SystemPaths {
+public:
+
+       /**
+        * Constructor
+        * this class should only be instanciated by GHOST_ISystem.
+        */
+       GHOST_SystemPathsX11();
+       
+       /**
+        * Destructor.
+        */
+       virtual ~GHOST_SystemPathsX11();
+
+       /**
+        * Determine the base dir in which shared resources are located. It will first try to use
+        * "unpack and run" path, then look for properly installed path, not including versioning.
+        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
+        */
+       const GHOST_TUns8* getSystemDir() const;
+
+       /**
+        * Determine the base dir in which user configuration is stored, not including versioning.
+        * If needed, it will create the base directory.
+        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
+        */
+       const GHOST_TUns8* getUserDir() const;
+
+       /**
+         * Determine the directory of the current binary
+         * @return Unsigned char string pointing to the binary dir
+         */
+        const GHOST_TUns8* getBinaryDir() const;
+
+};
+
+#endif
+
index a458d2d..df968d3 100644 (file)
@@ -851,7 +851,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
                                         * specifies a character code generated by a dead key. A dead key is a key that 
                                         * generates a character, such as the umlaut (double-dot), that is combined with 
                                         * another character to form a composite character. For example, the umlaut-O 
-                                        * character (Ö) is generated by typing the dead key for the umlaut character, and
+                                        * character (Ö) is generated by typing the dead key for the umlaut character, and
                                         * then typing the O key.
                                         */
                                case WM_SYSDEADCHAR:
@@ -1209,39 +1209,3 @@ void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const
                return;
        }
 }
-
-const GHOST_TUns8* GHOST_SystemWin32::getSystemDir() const
-{
-       static char knownpath[MAX_PATH];
-       HRESULT hResult = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath);
-
-       if (hResult == S_OK)
-       {
-               return (GHOST_TUns8*)knownpath;
-       }
-
-       return NULL;
-}
-
-const GHOST_TUns8* GHOST_SystemWin32::getUserDir() const
-{
-       static char knownpath[MAX_PATH];
-       HRESULT hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, knownpath);
-
-       if (hResult == S_OK)
-       {
-               return (GHOST_TUns8*)knownpath;
-       }
-
-       return NULL;
-}
-
-const GHOST_TUns8* GHOST_SystemWin32::getBinaryDir() const
-{
-       static char fullname[MAX_PATH];
-       if(GetModuleFileName(0, fullname, MAX_PATH)) {
-               return (GHOST_TUns8*)fullname;
-       }
-
-       return NULL;
-}
index bda0c9f..29f4e64 100644 (file)
@@ -187,26 +187,6 @@ public:
         */
        virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
 
-       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/).
-        */
-       virtual const GHOST_TUns8* getSystemDir() const;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/).
-        */
-        virtual const GHOST_TUns8* getUserDir() const;
-
-        /**
-         * Determine the directory of the current binary
-         * @return Unsigned char string pointing to the binary dir
-         */
-        virtual const GHOST_TUns8* getBinaryDir() const;
-
        /**
         * Creates a drag'n'drop event and pushes it immediately onto the event queue. 
         * Called by GHOST_DropTargetWin32 class.
index 5f7c59f..5e63cc4 100644 (file)
@@ -1476,23 +1476,4 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const
        }
 }
 
-const GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
-{
-       return (GHOST_TUns8*) PREFIX "/share";
-}
-
-const GHOST_TUns8* GHOST_SystemX11::getUserDir() const
-{
-       char* env = getenv("HOME");
-       if(env) {
-               return (GHOST_TUns8*) env;
-       } else {
-               return NULL;
-       }
-}
-
-const GHOST_TUns8* GHOST_SystemX11::getBinaryDir() const
-{
-       return NULL;
-}
 
index 13ad420..6a4ff1b 100644 (file)
@@ -226,26 +226,6 @@ public:
         */
        void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
 
-       /**
-        * Determine the base dir in which shared resources are located. It will first try to use
-        * "unpack and run" path, then look for properly installed path, not including versioning.
-        * @return Unsigned char string pointing to system dir (eg /usr/share/blender/).
-        */
-       const GHOST_TUns8* getSystemDir() const;
-
-       /**
-        * Determine the base dir in which user configuration is stored, not including versioning.
-        * If needed, it will create the base directory.
-        * @return Unsigned char string pointing to user dir (eg ~/.blender/).
-        */
-       const GHOST_TUns8* getUserDir() const;
-
-       /**
-         * Determine the directory of the current binary
-         * @return Unsigned char string pointing to the binary dir
-         */
-        const GHOST_TUns8* getBinaryDir() const;
-
        /**
         * Atom used for ICCCM, WM-spec and Motif.
         * We only need get this atom at the start, it's relative
index a251ce2..016577f 100644 (file)
@@ -35,7 +35,7 @@ DIR = $(OCGDIR)/intern/$(LIBNAME)
 
 CCSRCS = GHOST_Buttons.cpp GHOST_System.cpp GHOST_Window.cpp
 CCSRCS += GHOST_EventManager.cpp GHOST_EventPrinter.cpp GHOST_WindowManager.cpp
-CCSRCS += GHOST_ISystem.cpp GHOST_ModifierKeys.cpp GHOST_TimerManager.cpp
+CCSRCS += GHOST_ISystem.cpp GHOST_ISystemPaths.cpp GHOST_ModifierKeys.cpp GHOST_TimerManager.cpp
 CCSRCS += GHOST_Rect.cpp GHOST_DisplayManager.cpp GHOST_C-api.cpp
 CCSRCS += GHOST_CallbackEventConsumer.cpp
 CCSRCS += GHOST_NDOFManager.cpp GHOST_Path-api.cpp
index 7eefacc..89a7598 100644 (file)
@@ -68,6 +68,7 @@
 #ifdef WITH_GAMEENGINE
 #include "SYS_System.h"
 #endif
+#include "GHOST_Path-api.h"
 
 #include "RNA_define.h"
 
@@ -118,6 +119,8 @@ void WM_init(bContext *C, int argc, char **argv)
                wm_ghost_init(C);       /* note: it assigns C to ghost! */
                wm_init_cursor_data();
        }
+       GHOST_CreateSystemPaths();
+
        wm_operatortype_init();
        
        set_free_windowmanager_cb(wm_close_and_free);   /* library.c */
@@ -443,6 +446,9 @@ void WM_exit(bContext *C)
 #ifdef WITH_GAMEENGINE
        SYS_DeleteSystem(SYS_GetSystem());
 #endif
+       
+       GHOST_DisposeSystemPaths();
+
        if(MEM_get_memory_blocks_in_use()!=0) {
                printf("Error Totblock: %d\n", MEM_get_memory_blocks_in_use());
                MEM_printmemlist();