shell32: Symlink the Downloads and Templates folders too.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Alex Henrie 2019-12-02 19:17:56 -07:00 committed by Alexandre Julliard
parent fc17535eb9
commit 477ff7e034
1 changed files with 34 additions and 18 deletions

View File

@ -4366,6 +4366,12 @@ static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) {
case IDS_MYVIDEOS: case IDS_MYVIDEOS:
lstrcpyW(wszSubPath, My_VideosW); lstrcpyW(wszSubPath, My_VideosW);
break; break;
case IDS_DOWNLOADS:
lstrcpyW(wszSubPath, DownloadsW);
break;
case IDS_TEMPLATES:
lstrcpyW(wszSubPath, TemplatesW);
break;
default: default:
ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath)); ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath));
return FALSE; return FALSE;
@ -4392,21 +4398,21 @@ static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) {
/****************************************************************************** /******************************************************************************
* _SHCreateSymbolicLinks [Internal] * _SHCreateSymbolicLinks [Internal]
* *
* Sets up symbol links for various shell folders to point into the users home * Sets up symbol links for various shell folders to point into the user's home
* directory. We do an educated guess about what the user would probably want: * directory. We do an educated guess about what the user would probably want:
* - If there is a 'My Documents' directory in $HOME, the user probably wants * - If there is a 'My Documents' directory in $HOME, the user probably wants
* wine's 'My Documents' to point there. Furthermore, we imply that the user * wine's 'My Documents' to point there. Furthermore, we infer that the user
* is a Windows lover and has no problem with wine creating 'My Pictures', * is a Windows lover and has no problem with wine creating subfolders for
* 'My Music' and 'My Videos' subfolders under '$HOME/My Documents', if those * 'My Pictures', 'My Music', 'My Videos' etc. under '$HOME/My Documents', if
* do not already exits. We put appropriate symbolic links in place for those, * those do not already exist. We put appropriate symbolic links in place for
* too. * those, too.
* - If there is no 'My Documents' directory in $HOME, we let 'My Documents' * - If there is no 'My Documents' directory in $HOME, we let 'My Documents'
* point directly to $HOME. We assume the user to be a unix hacker who does not * point directly to $HOME. We assume the user to be a unix hacker who does not
* want wine to create anything anywhere besides the .wine directory. So, if * want wine to create anything anywhere besides the .wine directory. So, if
* there already is a 'My Music' directory in $HOME, we symlink the 'My Music' * there already is a 'My Music' directory in $HOME, we symlink the 'My Music'
* shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known" * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known"
* directory, and try to link to that. If that fails, then we symlink to * directory, and try to link to that. If that fails, then we symlink to
* $HOME directly. The same holds fo 'My Pictures' and 'My Videos'. * $HOME directly. The same holds for 'My Pictures', 'My Videos' etc.
* - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not * - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not
* exist, then we try '$HOME/Desktop'. If that does not exist, then we leave * exist, then we try '$HOME/Desktop'. If that does not exist, then we leave
* it alone. * it alone.
@ -4414,10 +4420,18 @@ static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) {
*/ */
static void _SHCreateSymbolicLinks(void) static void _SHCreateSymbolicLinks(void)
{ {
UINT aidsMyStuff[] = { IDS_MYPICTURES, IDS_MYVIDEOS, IDS_MYMUSIC }, i; static const UINT aidsMyStuff[] = {
const WCHAR* MyOSXStuffW[] = { PicturesW, MoviesW, MusicW }; IDS_MYPICTURES, IDS_MYVIDEOS, IDS_MYMUSIC, IDS_DOWNLOADS, IDS_TEMPLATES
int acsidlMyStuff[] = { CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC }; };
static const char * const xdg_dirs[] = { "PICTURES", "VIDEOS", "MUSIC", "DOCUMENTS", "DESKTOP" }; static const WCHAR * const MyOSXStuffW[] = {
PicturesW, MoviesW, MusicW, DownloadsW, TemplatesW
};
static const int acsidlMyStuff[] = {
CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC, CSIDL_DOWNLOADS, CSIDL_TEMPLATES
};
static const char * const xdg_dirs[] = {
"PICTURES", "VIDEOS", "MUSIC", "DOWNLOAD", "TEMPLATES", "DOCUMENTS", "DESKTOP"
};
static const unsigned int num = ARRAY_SIZE(xdg_dirs); static const unsigned int num = ARRAY_SIZE(xdg_dirs);
WCHAR wszTempPath[MAX_PATH]; WCHAR wszTempPath[MAX_PATH];
char szPersonalTarget[FILENAME_MAX], *pszPersonal; char szPersonalTarget[FILENAME_MAX], *pszPersonal;
@ -4428,6 +4442,7 @@ static void _SHCreateSymbolicLinks(void)
HRESULT hr; HRESULT hr;
char ** xdg_results; char ** xdg_results;
char * xdg_desktop_dir; char * xdg_desktop_dir;
UINT i;
/* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */ /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
hr = SHGetFolderPathW(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, hr = SHGetFolderPathW(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL,
@ -4449,9 +4464,9 @@ static void _SHCreateSymbolicLinks(void)
if (_SHAppendToUnixPath(szPersonalTarget, MAKEINTRESOURCEW(IDS_PERSONAL)) && if (_SHAppendToUnixPath(szPersonalTarget, MAKEINTRESOURCEW(IDS_PERSONAL)) &&
!stat(szPersonalTarget, &statFolder) && S_ISDIR(statFolder.st_mode)) !stat(szPersonalTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
{ {
/* '$HOME/My Documents' exists. Create 'My Pictures', /* '$HOME/My Documents' exists. Create subfolders for
* 'My Videos' and 'My Music' subfolders or fail silently if * 'My Pictures', 'My Videos', 'My Music' etc. or fail silently
* they already exist. * if they already exist.
*/ */
for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++)
{ {
@ -4489,8 +4504,9 @@ static void _SHCreateSymbolicLinks(void)
} }
else else
{ {
/* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos' and 'My Music' subdirs /* '$HOME' doesn't exist. Create subdirs for 'My Pictures', 'My Videos',
* in '%USERPROFILE%\\My Documents' or fail silently if they already exist. */ * 'My Music' etc. in '%USERPROFILE%\My Documents' or fail silently if
* they already exist. */
pszHome = NULL; pszHome = NULL;
strcpy(szPersonalTarget, pszPersonal); strcpy(szPersonalTarget, pszPersonal);
for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) { for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) {
@ -4500,7 +4516,7 @@ static void _SHCreateSymbolicLinks(void)
} }
} }
/* Create symbolic links for 'My Pictures', 'My Videos' and 'My Music'. */ /* Create symbolic links for 'My Pictures', 'My Videos', 'My Music' etc. */
for (i=0; i < ARRAY_SIZE(aidsMyStuff); i++) for (i=0; i < ARRAY_SIZE(aidsMyStuff); i++)
{ {
/* Create the current 'My Whatever' folder and get its unix path. */ /* Create the current 'My Whatever' folder and get its unix path. */
@ -6136,7 +6152,7 @@ HRESULT SHELL_RegisterShellFolders(void)
HRESULT hr; HRESULT hr;
/* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures', /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures',
* 'My Videos', 'My Music' and 'Desktop' in advance, so that the * 'My Videos', 'My Music', 'Desktop' etc. in advance, so that the
* _SHRegister*ShellFolders() functions will find everything nice and clean * _SHRegister*ShellFolders() functions will find everything nice and clean
* and thus will not attempt to create them in the profile directory. */ * and thus will not attempt to create them in the profile directory. */
_SHCreateSymbolicLinks(); _SHCreateSymbolicLinks();