[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26942] trunk/blender/intern/ghost: System dependant functions (skeletons) to retrieve user and system base dirs.

gsr b3d gsr.b3d at infernal-iceberg.com
Mon Feb 15 23:50:53 CET 2010


Revision: 26942
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26942
Author:   gsrb3d
Date:     2010-02-15 23:50:53 +0100 (Mon, 15 Feb 2010)

Log Message:
-----------
System dependant functions (skeletons) to retrieve user and system base dirs.
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

Modified Paths:
--------------
    trunk/blender/intern/ghost/GHOST_C-api.h
    trunk/blender/intern/ghost/GHOST_ISystem.h
    trunk/blender/intern/ghost/intern/GHOST_C-api.cpp
    trunk/blender/intern/ghost/intern/GHOST_System.h
    trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp
    trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.h
    trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h
    trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
    trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
    trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h
    trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
    trunk/blender/intern/ghost/intern/GHOST_SystemX11.h

Modified: trunk/blender/intern/ghost/GHOST_C-api.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_C-api.h	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/GHOST_C-api.h	2010-02-15 22:50:53 UTC (rev 26942)
@@ -819,6 +819,21 @@
  */
 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

Modified: trunk/blender/intern/ghost/GHOST_ISystem.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_ISystem.h	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/GHOST_ISystem.h	2010-02-15 22:50:53 UTC (rev 26942)
@@ -371,6 +371,24 @@
 	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.

Modified: trunk/blender/intern/ghost/intern/GHOST_C-api.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_C-api.cpp	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/intern/GHOST_C-api.cpp	2010-02-15 22:50:53 UTC (rev 26942)
@@ -855,3 +855,14 @@
 	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();
+}

Modified: trunk/blender/intern/ghost/intern/GHOST_System.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_System.h	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/intern/GHOST_System.h	2010-02-15 22:50:53 UTC (rev 26942)
@@ -297,6 +297,20 @@
 	   */
 	  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.

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp	2010-02-15 22:50:53 UTC (rev 26942)
@@ -1215,3 +1215,12 @@
 	}
 }
 
+GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
+{
+
+}
+
+GHOST_TUns8* GHOST_SystemX11::getUserDir() const
+{
+
+}

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.h	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.h	2010-02-15 22:50:53 UTC (rev 26942)
@@ -190,6 +190,20 @@
 	 */
 	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.

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h	2010-02-15 22:50:53 UTC (rev 26942)
@@ -214,6 +214,20 @@
 	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
 	 * @param window The window on which the event occured

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2010-02-15 22:50:53 UTC (rev 26942)
@@ -1736,3 +1736,13 @@
 	
 	[pool drain];
 }
+
+GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
+{
+
+}
+
+GHOST_TUns8* GHOST_SystemX11::getUserDir() const
+{
+
+}

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2010-02-15 22:50:53 UTC (rev 26942)
@@ -1095,3 +1095,12 @@
 	}
 }
 
+GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
+{
+
+}
+
+GHOST_TUns8* GHOST_SystemX11::getUserDir() const
+{
+
+}

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h	2010-02-15 22:50:53 UTC (rev 26942)
@@ -187,7 +187,22 @@
 	 */
 	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.
 	 * @param eventType The type of drag'n'drop event

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2010-02-15 22:50:53 UTC (rev 26942)
@@ -1457,3 +1457,22 @@
 			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;
+	}
+}

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemX11.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemX11.h	2010-02-15 21:07:14 UTC (rev 26941)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemX11.h	2010-02-15 22:50:53 UTC (rev 26942)
@@ -227,6 +227,20 @@
 	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.

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list