[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29947] trunk/blender: Patch [#22339] File /installation paths changes

Andrea Weikert elubie at gmx.net
Sun Jul 4 23:15:00 CEST 2010


Revision: 29947
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29947
Author:   elubie
Date:     2010-07-04 23:14:59 +0200 (Sun, 04 Jul 2010)

Log Message:
-----------
Patch [#22339] File/installation paths changes

Update after discussions on IRC:
* operating system specific path retrieval is moved back to GHOST, nothing blender specific here though
* cleaned up path functions a bit to remove #ifdefs
* removed Cocoa from blenlib again

TODO:
* Matt, Damien, please check and correct the functions for Cocoa and Carbon, could only put back existing code but needs adjustment
* finish GHOST_getBinaryDir - this should replace the BLI_where_am_i eventually as well as BLI_getInstallationPath on Windows and get_install_dir for the blenderplayer runtime
* It would probably be nice to define GHOST_getTempDir as well and move those out
* more cleanups...

NOTE:
Things are likely broken for macs

Modified Paths:
--------------
    trunk/blender/intern/ghost/CMakeLists.txt
    trunk/blender/intern/ghost/GHOST_ISystem.h
    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
    trunk/blender/source/blender/blenlib/BLI_path_util.h
    trunk/blender/source/blender/blenlib/CMakeLists.txt
    trunk/blender/source/blender/blenlib/intern/path_util.c

Added Paths:
-----------
    trunk/blender/intern/ghost/GHOST_Path-api.h
    trunk/blender/intern/ghost/intern/GHOST_Path-api.cpp

Removed Paths:
-------------
    trunk/blender/source/blender/blenlib/intern/path_util_cocoa.mm

Modified: trunk/blender/intern/ghost/CMakeLists.txt
===================================================================
--- trunk/blender/intern/ghost/CMakeLists.txt	2010-07-04 20:59:10 UTC (rev 29946)
+++ trunk/blender/intern/ghost/CMakeLists.txt	2010-07-04 21:14:59 UTC (rev 29947)
@@ -42,6 +42,7 @@
 	${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_ISystem.cpp
 	${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_ModifierKeys.cpp
 	${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_NDOFManager.cpp
+	${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_Path-api.cpp
 	${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_Rect.cpp
 	${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_System.cpp
 	${CMAKE_CURRENT_SOURCE_DIR}/intern/GHOST_TimerManager.cpp

Modified: trunk/blender/intern/ghost/GHOST_ISystem.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_ISystem.h	2010-07-04 20:59:10 UTC (rev 29946)
+++ trunk/blender/intern/ghost/GHOST_ISystem.h	2010-07-04 21:14:59 UTC (rev 29947)
@@ -370,7 +370,25 @@
 	 */
 	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.

Added: trunk/blender/intern/ghost/GHOST_Path-api.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_Path-api.h	                        (rev 0)
+++ trunk/blender/intern/ghost/GHOST_Path-api.h	2010-07-04 21:14:59 UTC (rev 29947)
@@ -0,0 +1,63 @@
+/**
+ *
+ * ***** 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 by Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef	GHOST_PATH_API_H
+#define GHOST_PATH_API_H
+
+#include "GHOST_Types.h"
+
+#ifdef __cplusplus
+extern "C" { 
+#endif
+
+/**
+ * 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 const 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 const GHOST_TUns8* GHOST_getUserDir();
+
+
+/**
+ * Determine the dir in which the binary file is found.
+ * @return Unsigned char string pointing to binary dir (eg ~/usr/local/bin/).
+ */
+extern const GHOST_TUns8* GHOST_getBinaryDir();
+
+#ifdef __cplusplus
+} 
+#endif
+
+#endif
\ No newline at end of file


Property changes on: trunk/blender/intern/ghost/GHOST_Path-api.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/blender/intern/ghost/intern/GHOST_Path-api.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_Path-api.cpp	                        (rev 0)
+++ trunk/blender/intern/ghost/intern/GHOST_Path-api.cpp	2010-07-04 21:14:59 UTC (rev 29947)
@@ -0,0 +1,49 @@
+/**
+ *
+ * ***** 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 by Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "intern/GHOST_Debug.h"
+#include "GHOST_path-api.h"
+#include "GHOST_ISystem.h"
+
+const GHOST_TUns8* GHOST_getSystemDir()
+{
+	GHOST_ISystem* system = GHOST_ISystem::getSystem();
+	return system->getSystemDir();
+}
+
+const GHOST_TUns8* GHOST_getUserDir()
+{
+	GHOST_ISystem* system = GHOST_ISystem::getSystem();
+	return system->getUserDir();
+}
+
+const GHOST_TUns8* GHOST_getBinaryDir()
+{
+	GHOST_ISystem* system = GHOST_ISystem::getSystem();
+	return system->getBinaryDir();
+}
\ No newline at end of file


Property changes on: trunk/blender/intern/ghost/intern/GHOST_Path-api.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/blender/intern/ghost/intern/GHOST_System.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_System.h	2010-07-04 20:59:10 UTC (rev 29946)
+++ trunk/blender/intern/ghost/intern/GHOST_System.h	2010-07-04 21:14:59 UTC (rev 29947)
@@ -297,6 +297,25 @@
 	   */
 	  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.

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp	2010-07-04 20:59:10 UTC (rev 29946)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp	2010-07-04 21:14:59 UTC (rev 29947)
@@ -1214,3 +1214,29 @@
 		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
+{
+	return NULL;
+}

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.h	2010-07-04 20:59:10 UTC (rev 29946)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCarbon.h	2010-07-04 21:14:59 UTC (rev 29947)
@@ -190,6 +190,27 @@
 	 */
 	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.

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h	2010-07-04 20:59:10 UTC (rev 29946)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h	2010-07-04 21:14:59 UTC (rev 29947)
@@ -214,6 +214,26 @@
 	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.

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list