[PATCH 11/11] shell32: _SHAppendToUnixPath() refactor and remove Resource ID string matching code

Rob Walker bob.mt.wya at gmail.com
Mon Jul 16 17:47:05 CDT 2018


The only call(s) to this function, with a Resource ID string, have been removed from
_SHCreateSymbolicLinks(). So we can remove support for this.
Correctly handle a zero length base path string (which would segfault the pre-existing
implementation).

Signed-off-by: Rob Walker <bob.mt.wya at gmail.com>
---
 dlls/shell32/shellpath.c | 42 +++++++++-------------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index 6c6d879cb6..5b12080b4a 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -4328,13 +4328,12 @@ static HRESULT _SHRegisterCommonShellFolders(void)
 /******************************************************************************
  * _SHAppendToUnixPath  [Internal]
  *
- * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath (or the 
- * corresponding resource, if IS_INTRESOURCE) to the unix base path 'szBasePath' 
- * and replaces backslashes with slashes.
+ * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath to the Unix
+ * base path 'szBasePath' and replaces backslashes with slashes.
  *
  * PARAMS
  *  szBasePath  [IO] The unix base path, which will be appended to (CP_UNXICP).
- *  pwszSubPath [I]  Sub-path or resource id (use MAKEINTRESOURCEW).
+ *  pwszSubPath [I]  Sub-path.
  *
  * RETURNS
  *  Success: TRUE,
@@ -4345,42 +4344,19 @@ static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) {
     int cLen = strlen(szBasePath);
     char *pBackslash;
 
-    if (IS_INTRESOURCE(pwszSubPath)) {
-        if (!LoadStringW(shell32_hInstance, LOWORD(pwszSubPath), wszSubPath, MAX_PATH)) {
-            /* Fall back to hard coded defaults. */
-            switch (LOWORD(pwszSubPath)) {
-                case IDS_PERSONAL:
-                    lstrcpyW(wszSubPath, DocumentsW);
-                    break;
-                case IDS_MYMUSIC:
-                    lstrcpyW(wszSubPath, MusicW);
-                    break;
-                case IDS_MYPICTURES:
-                    lstrcpyW(wszSubPath, PicturesW);
-                    break;
-                case IDS_MYVIDEOS:
-                    lstrcpyW(wszSubPath, VideosW);
-                    break;
-                default:
-                    ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath));
-                    return FALSE;
-            }
-        }
-    } else {
-        lstrcpyW(wszSubPath, pwszSubPath);
-    }
- 
-    if (szBasePath[cLen-1] != '/') szBasePath[cLen++] = '/';
- 
+    lstrcpyW(wszSubPath, pwszSubPath);
+
+    if (!cLen || (szBasePath[cLen-1] != '/')) szBasePath[cLen++] = '/';
+
     if (!WideCharToMultiByte(CP_UNIXCP, 0, wszSubPath, -1, szBasePath + cLen,
                              FILENAME_MAX - cLen, NULL, NULL))
     {
         return FALSE;
     }
- 
+
     pBackslash = szBasePath + cLen;
     while ((pBackslash = strchr(pBackslash, '\\'))) *pBackslash = '/';
- 
+
     return TRUE;
 }
 
-- 
2.18.0




More information about the wine-devel mailing list