System dependant functions (skeletons) to retrieve user and system base dirs.
authorGuillermo S. Romero <gsr.b3d@infernal-iceberg.com>
Mon, 15 Feb 2010 22:50:53 +0000 (22:50 +0000)
committerGuillermo S. Romero <gsr.b3d@infernal-iceberg.com>
Mon, 15 Feb 2010 22:50:53 +0000 (22:50 +0000)
Thus #defines in BLI_bfile.c can be dropped, as suggested by Damien Plisson.
Feel free to fill in the non Unix ones. For extra info see:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/ResourceFilePaths
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/EnvironmentVariables

12 files changed:
intern/ghost/GHOST_C-api.h
intern/ghost/GHOST_ISystem.h
intern/ghost/intern/GHOST_C-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_SystemWin32.cpp
intern/ghost/intern/GHOST_SystemWin32.h
intern/ghost/intern/GHOST_SystemX11.cpp
intern/ghost/intern/GHOST_SystemX11.h

index 8e254ce9c3225bcd2fb2fbcd7be4bcc62c6c7140..75a055075bcf4d9af90dee7a8f5ef3d991084019 100644 (file)
@@ -819,6 +819,21 @@ extern GHOST_TUns8* GHOST_getClipboard(int selection);
  */
 extern void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection);
 
+/**
+ * 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/).
+ */
+extern GHOST_TUns8* GHOST_getSystemDir();
+
+/**
+ * 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/).
+ */
+extern GHOST_TUns8* GHOST_getUserDir();
+
+
 #ifdef __cplusplus
 }
 #endif
index 8e9ac2b51ffce5c1af0d5f7d32522f3c56013cbd..5e0c7f41ab87be93749f8eb19cdc2e74d2932afa 100644 (file)
@@ -371,6 +371,24 @@ public:
        virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
 
        
+       /***************************************************************************************
+        ** Determine special paths.
+        ***************************************************************************************/
+
+       /**
+        * 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 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 GHOST_TUns8* getUserDir() const = 0;
+
 protected:
        /**
         * Initialize the system.
index 6a9c59bc897b8bbbeac1f6514558a15007ba43de..fd06d7620ab485252bfd94269cb93ef2c4a9ceb3 100644 (file)
@@ -855,3 +855,14 @@ void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection)
        system->putClipboard(buffer, selection);
 }
 
+GHOST_TUns8* GHOST_getSystemDir()
+{
+       GHOST_ISystem* system = GHOST_ISystem::getSystem();
+       return system->getSystemDir();
+}
+
+GHOST_TUns8* GHOST_getUserDir()
+{
+       GHOST_ISystem* system = GHOST_ISystem::getSystem();
+       return system->getUserDir();
+}
index 2b45bfb86cf781213a1eb179ce27dab519d29d34..59f933ea8651b2591129326505de120894a75cb7 100644 (file)
@@ -297,6 +297,20 @@ 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 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 GHOST_TUns8* getUserDir() const = 0;
+
 protected:
        /**
         * Initialize the system.
index b2ca5a915a92c201979ccef4085eef02d2e3a24a..763cc9edde3b0b95cbc877d763d5aea2a3669c46 100644 (file)
@@ -1215,3 +1215,12 @@ void GHOST_SystemCarbon::putClipboard(GHOST_TInt8 *buffer, bool selection) const
        }
 }
 
+GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
+{
+
+}
+
+GHOST_TUns8* GHOST_SystemX11::getUserDir() const
+{
+
+}
index 9e270e6499062b638d0873b65fa08a73a77eeba0..b27d7917377953c418d302e2585011c04c6dcb6d 100644 (file)
@@ -190,6 +190,20 @@ 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 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 GHOST_TUns8* getUserDir() const;
+
 protected:
        /**
         * Initializes the system.
index 67b97dd7a1eae66434cf93eea6cc8299db9a09e8..c533e5510658c2ae026fd72d40d82490228ace50 100644 (file)
@@ -213,6 +213,20 @@ 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 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 GHOST_TUns8* getUserDir() const = 0;
+
        /**
      * Handles a window event. Called by GHOST_WindowCocoa window delegate
      * @param eventType The type of window event
index 90dad2f1d96b147127d2e7c49303546fd7418b15..382089283d34323e6cb77e87ba3b9c5a555ae51c 100644 (file)
@@ -1736,3 +1736,13 @@ void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const
        
        [pool drain];
 }
+
+GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
+{
+
+}
+
+GHOST_TUns8* GHOST_SystemX11::getUserDir() const
+{
+
+}
index e6422d254949d3e9be0359e228e6fb10eaf88d0d..6695bd56727bb1e407cee1afc04b222e6f1818aa 100644 (file)
@@ -1095,3 +1095,12 @@ void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const
        }
 }
 
+GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
+{
+
+}
+
+GHOST_TUns8* GHOST_SystemX11::getUserDir() const
+{
+
+}
index dd0b6dee0ed3b0806ebaec9014c44d50cf84257c..1b7b2aad76665e68ccda093745d3137a340dd3f1 100644 (file)
@@ -187,6 +187,21 @@ 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/).
+        */
+       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/).
+        */
+        GHOST_TUns8* getUserDir() const;
+
        /**
         * Creates a drag'n'drop event and pushes it immediately onto the event queue. 
         * Called by GHOST_DropTargetWin32 class.
index fc99ffbdd473f0d7780340735de3def3b957da41..5eab71eebf5d5a29303b640cc7776682ad80f8f6 100644 (file)
@@ -1457,3 +1457,22 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const
                        fprintf(stderr, "failed to own primary\n");
        }
 }
+
+GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
+{
+
+}
+
+GHOST_TUns8* GHOST_SystemX11::getUserDir() const
+{
+       char* path;
+       char* env = getenv("HOME");
+       if(env) {
+               path = (char*) malloc(strlen(env) + 10); // "/.blender/"
+               strcat(path, env);
+               strcat(path, "/,blender/");
+               return (GHOST_TUns8*) path;
+       } else {
+               return NULL;
+       }
+}
index 1620d52ee651b4b4b5d1449db942a1ef8411938f..b839b5a057a6ff1cee7dc2d47ebb7ea3e4a44fcc 100644 (file)
@@ -226,6 +226,20 @@ 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/).
+        */
+       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/).
+        */
+       GHOST_TUns8* getUserDir() const;
+
        /**
         * Atom used for ICCCM, WM-spec and Motif.
         * We only need get this atom at the start, it's relative