[PATCH 02/11] shell32: _SHCreateSymbolicLinks() flatten media directory creation
Rob Walker
bob.mt.wya at gmail.com
Mon Jul 16 17:46:56 CDT 2018
Remove loops to create 'My Pictures', 'My Videos' and 'My Music' subdirectories
in the '%USERPROFILE%\\My Documents' directory.
Flatten User Profile media profile directory symlink targets, so they are direct
subdirectories of $HOME.
If $HOME is not set, do not create any external symlinks for the User Profile
media directories (it's not clear what the use case is for supporting an XDG_XXX_DIR,
without $HOME set).
Signed-off-by: Rob Walker <bob.mt.wya at gmail.com>
---
dlls/shell32/shellpath.c | 45 +++++++++-------------------------------
1 file changed, 10 insertions(+), 35 deletions(-)
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index 0d8a5987d7..ee5274b5fc 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -4435,7 +4435,10 @@ static void _SHCreateSymbolicLinks(void)
if (FAILED(hr)) xdg_results = NULL;
pszHome = getenv("HOME");
- if (pszHome && !stat(pszHome, &statFolder) && S_ISDIR(statFolder.st_mode))
+ if (!(pszHome && !stat(pszHome, &statFolder) && S_ISDIR(statFolder.st_mode)))
+ pszHome = NULL;
+
+ if (pszHome)
{
while (1)
{
@@ -4443,19 +4446,7 @@ static void _SHCreateSymbolicLinks(void)
strcpy(szPersonalTarget, pszHome);
if (_SHAppendToUnixPath(szPersonalTarget, MAKEINTRESOURCEW(IDS_PERSONAL)) &&
!stat(szPersonalTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
- {
- /* '$HOME/My Documents' exists. Create 'My Pictures',
- * 'My Videos' and 'My Music' subfolders 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);
- }
break;
- }
/* Try to target the XDG_DOCUMENTS_DIR folder. */
if (xdg_results && xdg_results[num-2])
@@ -4477,18 +4468,6 @@ static void _SHCreateSymbolicLinks(void)
remove(pszPersonal);
symlink(szPersonalTarget, pszPersonal);
}
- else
- {
- /* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos' and 'My Music' subdirs
- * in '%USERPROFILE%\\My Documents' or fail silently if 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);
- }
- }
/* Create symbolic links for 'My Pictures', 'My Videos' and 'My Music'. */
for (i=0; i < ARRAY_SIZE(aidsMyStuff); i++)
@@ -4496,7 +4475,7 @@ static void _SHCreateSymbolicLinks(void)
/* Create the '%USERPROFILE%\\My XXX' directory path. */
hr = SHGetFolderPathW(NULL, acsidlMyStuff[i]|CSIDL_FLAG_CREATE, NULL,
SHGFP_TYPE_DEFAULT, wszTempPath);
- if (FAILED(hr)) continue;
+ if (FAILED(hr) || !pszHome) continue;
pszMyStuff = wine_get_unix_file_name(wszTempPath);
if (!pszMyStuff) continue;
@@ -4504,7 +4483,7 @@ static void _SHCreateSymbolicLinks(void)
while (1)
{
/* Try to target a pre-existing '$HOME/My Documents/My XXX' folder. */
- strcpy(szMyStuffTarget, szPersonalTarget);
+ strcpy(szMyStuffTarget, pszHome);
if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])) &&
!stat(szMyStuffTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
break;
@@ -4517,14 +4496,10 @@ static void _SHCreateSymbolicLinks(void)
}
/* Try to target the hardcoded / OS X 'XXX' folder. */
- if (pszHome)
- {
- strcpy(szMyStuffTarget, pszHome);
- if (_SHAppendToUnixPath(szMyStuffTarget, MyOSXStuffW[i]) &&
- !stat(szMyStuffTarget, &statFolder) &&
- S_ISDIR(statFolder.st_mode))
- break;
- }
+ strcpy(szMyStuffTarget, pszHome);
+ if (_SHAppendToUnixPath(szMyStuffTarget, MyOSXStuffW[i]) &&
+ !stat(szMyStuffTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
+ break;
/* Use the same target as '%USERPROFILE%\\My Documents' (fallback). */
strcpy(szMyStuffTarget, szPersonalTarget);
--
2.18.0
More information about the wine-devel
mailing list