
/*
	NSWorkspace: Return the user's temporary directory
	Original Source: <http://cocoa.karelia.com/AppKit_Categories/NSWorkspace__Return.m>
	(See copyright notice at <http://cocoa.karelia.com>)
*/

/*"	Return the user's temporary directory path.  Sure, you could just hard-wire something in /tmp, but this is wraps the official Carbon FindFolder technique.
"*/

- (NSString *) temporaryDirectory
{
	char	s[1024];
	FSSpec	spec;
	FSRef	ref;
	short	vRefNum;
	long	dirID;
	
	if ( FindFolder( kOnAppropriateDisk, kChewableItemsFolderType, true,
			&vRefNum, &dirID ) == noErr )
	{
		FSMakeFSSpec( vRefNum, dirID, "", &spec );
		if ( FSpMakeFSRef(&spec, &ref) == noErr )
		{
			FSRefMakePath(&ref, s, sizeof(s));
			return [NSString stringWithUTF8String:s];
			// not sure if s is in UTF8 encoding:  What's opposite of -[NSString fileSystemRepresentation]?
		}
	}
	return nil;
}