Jump to content
3DCoat Forums

Vista Compatible Storage


David Walters
 Share

Recommended Posts

  • Advanced Member

Hi, I hope you don't mind me posting a code snippet, but I have solved this problem already and it's good to share, right :)

My initial request is: Can you change 3d-Coat to read shaders from the user data folder as well as the installation directory?

The code I've posted below will generate a valid path (on both XP and Vista) to the user's application data folder, either:

C:\Users\%user%\AppData\Roaming (on Vista) or

C:\Documents and Settings\%user%\Application Data\ (on XP)

where you are free to read and write data without any access restrictions.

The reason I ask is that, as you probably know, files written to the Program Files folder normally, actually end up being written instead to the "virtual store" ( C:\Users\%user%\AppData\Local\VirtualStore ) which can lead to a variety of problems with mismatches, etc. - as you can imagine.

Ultimately I'd love to see all of the volatile data that 3d-Coat uses (undo, etc.) to use the user data folder:

* Avoid the need for the UAC elevation on startup which looks a little bit unprofessional (sorry!)

* Allow UNDO to live on a different disk, which might help people with a small C: partition and their user folder on some other drive?

* Allow editing of shaders in this location without UAC interfering, this might help developers?

* License data file can exist even when you uninstall, or install in a different directory?

I've probably not explained myself very clearly and I can hopefully clarify what I mean, I found this quite a hard issue to explain :)

I'm sure it probably doesn't seem like such a big thing either, but I think making an application that lives harmoniously with Vista is a good long term goal.

char profile_folder[ MAX_PATH ];

if SUCCEEDED( SHGetFolderPath( NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, 
	NULL, SHGFP_TYPE_CURRENT, profile_folder ) )
{
	// Append company / title suffix
	strcat_s( profile_folder, sizeof( profile_folder ), "\\Pilgway\\3d-Coat\\" );

	// Get the base length
	const size_t length = strlen( profile_folder );

	// Create Directory Tree, skip drive
	for ( unsigned int i = 2; i < length; ++i )
	{
		if ( profile_folder[ i ] == '\\' || profile_folder[ i ] == '/' )
		{
			// Briefly turn into a NULL terminated c-string
			profile_folder[ i ] = NULL;
			_mkdir( profile_folder );
			profile_folder[ i ] = '\\';
		}
	}

	// Create home directory
	_mkdir( profile_folder );

	// Debug
	printf( "home_path = %s\n", profile_folder );
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...