From 7642388153992fc7f1efbe5688397ff2607d4c37 Mon Sep 17 00:00:00 2001 From: "Olivier F. R. Dierick" Date: Wed, 19 Feb 2020 00:16:38 +0100 Subject: [PATCH] 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 Signed-off-by: Alexandre Julliard --- dlls/shell32/shellpath.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 8caf68dc551..0a31ee76d7a 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -4050,6 +4050,33 @@ static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) { 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] * @@ -4122,12 +4149,7 @@ static void _SHCreateSymbolicLinks(void) * 'My Pictures', 'My Videos', 'My Music' etc. or fail silently * if they already exist. */ - for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) - { - strcpy(szMyStuffTarget, szPersonalTarget); - if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i]))) - mkdir(szMyStuffTarget, 0777); - } + _SHCreateMyDocumentsSubDirs(aidsMyStuff, ARRAY_SIZE(aidsMyStuff), szPersonalTarget); break; } @@ -4163,11 +4185,7 @@ static void _SHCreateSymbolicLinks(void) * they already exist. */ pszHome = NULL; strcpy(szPersonalTarget, pszPersonal); - for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) { - strcpy(szMyStuffTarget, szPersonalTarget); - if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i]))) - mkdir(szMyStuffTarget, 0777); - } + _SHCreateMyDocumentsSubDirs(aidsMyStuff, ARRAY_SIZE(aidsMyStuff), szPersonalTarget); } /* Create symbolic links for 'My Pictures', 'My Videos', 'My Music' etc. */