shell32: Add a helper function to create 'My Stuff' sub dirs in 'My Documents'.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=22974
Signed-off-by: Olivier F. R. Dierick <o.dierick@piezo-forte.be>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Olivier F. R. Dierick 2020-02-19 00:16:38 +01:00 committed by Alexandre Julliard
parent 8c7c6e9b79
commit 7642388153
1 changed files with 29 additions and 11 deletions

View File

@ -4050,6 +4050,33 @@ static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) {
return TRUE; return TRUE;
} }
/******************************************************************************
* _SHCreateMyDocumentsSubDirs [Internal]
*
* Create real directories for various shell folders under 'My Documents'. For
* Windows and homeless styles. Fails silently for already existing sub dirs.
*
* PARAMS
* aidsMyStuff [I] Array of IDS_* resources to create sub dirs for.
* num [I] Number of elements in aidsMyStuff.
* szPersonalTarget [I] Unix path to 'My Documents' directory.
*/
static void _SHCreateMyDocumentsSubDirs(const UINT * aidsMyStuff, const UINT num, const char * szPersonalTarget)
{
char szMyStuffTarget[FILENAME_MAX];
UINT i;
if (aidsMyStuff && szPersonalTarget)
{
for (i = 0; i < num; i++)
{
strcpy(szMyStuffTarget, szPersonalTarget);
if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
mkdir(szMyStuffTarget, 0777);
}
}
}
/****************************************************************************** /******************************************************************************
* _SHCreateSymbolicLinks [Internal] * _SHCreateSymbolicLinks [Internal]
* *
@ -4122,12 +4149,7 @@ static void _SHCreateSymbolicLinks(void)
* 'My Pictures', 'My Videos', 'My Music' etc. or fail silently * 'My Pictures', 'My Videos', 'My Music' etc. or fail silently
* if they already exist. * if they already exist.
*/ */
for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) _SHCreateMyDocumentsSubDirs(aidsMyStuff, ARRAY_SIZE(aidsMyStuff), szPersonalTarget);
{
strcpy(szMyStuffTarget, szPersonalTarget);
if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
mkdir(szMyStuffTarget, 0777);
}
break; break;
} }
@ -4163,11 +4185,7 @@ static void _SHCreateSymbolicLinks(void)
* they already exist. */ * they already exist. */
pszHome = NULL; pszHome = NULL;
strcpy(szPersonalTarget, pszPersonal); strcpy(szPersonalTarget, pszPersonal);
for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) { _SHCreateMyDocumentsSubDirs(aidsMyStuff, ARRAY_SIZE(aidsMyStuff), szPersonalTarget);
strcpy(szMyStuffTarget, szPersonalTarget);
if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
mkdir(szMyStuffTarget, 0777);
}
} }
/* Create symbolic links for 'My Pictures', 'My Videos', 'My Music' etc. */ /* Create symbolic links for 'My Pictures', 'My Videos', 'My Music' etc. */