Getting a path to SUGAR_ACTVITY_ROOT

John Maloney jmaloney at media.mit.edu
Thu Sep 11 18:08:59 EDT 2008


Hi, Scott.

I wonder if you could give me a bit of guidance. The Scratch file  
dialogs have shortcuts for common folders on Windows and Mac, such as  
the desktop and the user's documents folder. Most of these shortcuts  
make no sense on the XO, but I thought that perhaps the documents  
shortcut could go to $SUGAR_ACTVITY_ROOT/data. But my first attempt to  
lookup that environment variable did not seem to work (although I have  
not tried it in the context of your new wrapper; maybe it does work  
now).

Anyhow, the code I wrote to do this is:

	char *s = NULL;

	path[0] = 0;  // a zero-length path indicates failure

	s = getenv("SUGAR_ACTVITY_ROOT");
	if (s != NULL) {
		strncat(path, s, maxPath);
		strncat(path, "/data", maxPath);
	}

where path is a C string passed in by the client that is supposed to  
get filled in with the path to documents folder.

I'm not used to programming in Unix. Does this look okay to you?

	-- John




More information about the Devel mailing list