[Mixmaster-devel] r777 - trunk/Mix/Src
Brought to you by:
weaselp
From: <we...@so...> - 2004-04-30 21:24:23
|
Author: weasel Date: 2004-04-30 23:24:16 +0200 (Fri, 30 Apr 2004) New Revision: 777 Modified: trunk/Mix/Src/mix.c Log: On Win32, default to Application Data/Mixmaster Modified: trunk/Mix/Src/mix.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/Mix/Src/mix.c 2004-04-27 00:41:25 UTC (rev 776) +++ trunk/Mix/Src/mix.c 2004-04-30 21:24:16 UTC (rev 777) @@ -29,6 +29,7 @@ #endif /* else if not POSIX */ #ifdef WIN32 #include <windows.h> +#include <shlobj.h> #endif /* WIN32 */ #include <assert.h> #include "menu.h" @@ -626,6 +627,21 @@ pw =3D getpwuid(getuid()); #endif /* POSIX */ =20 + /* find our base directory + * + * first match wins. + * + * - what the MIXPATH environment variable points to, if it is set. + * - On WIN32, HKEY_CURRENT_USER\Software\Mixmaster\MixDir, if it exis= ts + * - whatever is compiled in with -DSPOOL + * - On Win32 %APPDATA%\Mixmaster + * - on POSIX, ~/Mix (or ~/<HOMEMIXDIR>) + * - the current working directory + */ + + if (err =3D=3D -1 && (d =3D getenv("MIXPATH")) !=3D NULL) + err =3D mixdir(d, 1); + #ifdef WIN32 RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, ®sw)= ; len=3Dsizeof(line); @@ -637,14 +653,29 @@ } #endif /* WIN32 */ =20 - if (err =3D=3D -1 && (d =3D getenv("MIXPATH")) !=3D NULL) - err =3D mixdir(d, 1); - #ifdef SPOOL if (err =3D=3D -1 && strlen(SPOOL) > 0) err =3D mixdir(SPOOL, 0); #endif /* SPOOL */ =20 +#ifdef WIN32 + if (err =3D=3D -1) { + LPMALLOC *lpmalloc; + ITEMIDLIST *itemidlist; + if (SUCCEEDED(SHGetMalloc(&lpmalloc))) + { + SHGetSpecialFolderLocation(0,CSIDL_APPDATA,&itemidlist); + SHGetPathFromIDList(itemidlist,line); + lpmalloc->lpVtbl->Free(lpmalloc,&itemidlist); + lpmalloc->lpVtbl->Release(lpmalloc) + + strcatn(line, "\\Mixmaster", PATHMAX); + err =3D mixdir(line, 1); + + } + } +#endif /* WIN32 */ + #ifdef POSIX if (err =3D=3D -1 && pw !=3D NULL) { strncpy(line, pw->pw_dir, PATHMAX); |