[PATCH v2 3/9] shell32: Add a helper function to create 'My Stuff' sub dirs in 'My Documents'.
Olivier F. R. Dierick
o.dierick at piezo-forte.be
Tue Feb 18 17:16:38 CST 2020
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=22974
Signed-off-by: Olivier F. R. Dierick <o.dierick at piezo-forte.be>
---
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 8caf68d..0a31ee7 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -4051,6 +4051,33 @@ static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) {
}
/******************************************************************************
+ * _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]
*
* Sets up symbol links for various shell folders to point into the user's home
@@ -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. */
--
2.1.4
More information about the wine-devel
mailing list