[Bf-committers] HOME environment variable on Windows

Stealth Apprentice stealthapprentice at yahoo.com
Sat Jan 7 20:00:15 CET 2006

I've run into a tricky issue in using Blender. If
several applications in the pipeline already assume
HOME points to the actual user home directory, or the
project root directory, Blender doesn't play nicely
because of the code below (Listing One), which
constructs $(HOME)/.blender as the path instead of the
Blender installation path.

How do people usually deal with this sort of issue?

I can see a code solution to be:

1. check for BLENDER_HOME variable
2. else check for HOME variable
3. else check for installation directory

I can imagine some other solutions, but I don't like
them. For example, I don't like the idea of copying
from the installation to the user's home directory
because of maintenance issues.

Listing One

char *BLI_gethome(void) {
	#ifdef __BeOS
		return "/boot/home/";		/* BeOS 4.5: doubleclick at
icon doesnt give home env */

	#elif !defined(WIN32)
		return getenv("HOME");

	#else /* Windows */
		char * ret;
		static char dir[512];

		/* Check for %HOME% env var */

		ret = getenv("HOME");
		if(ret) {
			sprintf(dir, "%s\\.blender", ret);
			if (BLI_exists(dir)) return dir;

Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 

More information about the Bf-committers mailing list