[ros-diffs] [cwittich] 41308: import SHGetNewLinkInfoA/W from wine

cwittich at svn.reactos.org cwittich at svn.reactos.org
Sat Jun 6 17:45:11 CEST 2009


Author: cwittich
Date: Sat Jun  6 19:45:10 2009
New Revision: 41308

URL: http://svn.reactos.org/svn/reactos?rev=41308&view=rev
Log:
import SHGetNewLinkInfoA/W from wine

Modified:
    trunk/reactos/dll/win32/shell32/shell32_main.h
    trunk/reactos/dll/win32/shell32/shellord.c
    trunk/reactos/include/psdk/shellapi.h

Modified: trunk/reactos/dll/win32/shell32/shell32_main.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shell32_main.h?rev=41308&r1=41307&r2=41308&view=diff
==============================================================================
--- trunk/reactos/dll/win32/shell32/shell32_main.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shell32_main.h [iso-8859-1] Sat Jun  6 19:45:10 2009
@@ -38,9 +38,10 @@
 #include "shlobj.h"
 #include "shellapi.h"
 #include "wine/windef16.h"
+*/
 #include "wine/unicode.h"
 
-*/
+
 /*******************************************
 *  global SHELL32.DLL variables
 */

Modified: trunk/reactos/dll/win32/shell32/shellord.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shellord.c?rev=41308&r1=41307&r2=41308&view=diff
==============================================================================
--- trunk/reactos/dll/win32/shell32/shellord.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shellord.c [iso-8859-1] Sat Jun  6 19:45:10 2009
@@ -1972,20 +1972,72 @@
 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
                               UINT uFlags)
 {
-    FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_a(pszLinkTo), debugstr_a(pszDir),
-          pszName, pfMustCopy, uFlags);
-
-    return FALSE;
+    WCHAR wszLinkTo[MAX_PATH];
+    WCHAR wszDir[MAX_PATH];
+    WCHAR wszName[MAX_PATH];
+    BOOL res;
+
+    MultiByteToWideChar(CP_ACP, 0, pszLinkTo, -1, wszLinkTo, MAX_PATH);
+    MultiByteToWideChar(CP_ACP, 0, pszDir, -1, wszDir, MAX_PATH);
+
+    res = SHGetNewLinkInfoW(wszLinkTo, wszDir, wszName, pfMustCopy, uFlags);
+
+    if (res)
+        WideCharToMultiByte(CP_ACP, 0, wszName, -1, pszName, MAX_PATH, NULL, NULL);
+
+    return res;
 }
 
 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
                               UINT uFlags)
 {
-    FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
+    const WCHAR *basename;
+    WCHAR *dst_basename;
+    int i=2;
+    static const WCHAR lnkformat[] = {'%','s','.','l','n','k',0};
+    static const WCHAR lnkformatnum[] = {'%','s',' ','(','%','d',')','.','l','n','k',0};
+
+    TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
           pszName, pfMustCopy, uFlags);
 
-    return FALSE;
-}
+    *pfMustCopy = FALSE;
+
+    if (uFlags & SHGNLI_PIDL)
+    {
+        FIXME("SHGNLI_PIDL flag unsupported\n");
+        return FALSE;
+    }
+
+    if (uFlags)
+        FIXME("ignoring flags: 0x%08x\n", uFlags);
+
+    /* FIXME: should test if the file is a shortcut or DOS program */
+    if (GetFileAttributesW(pszLinkTo) == INVALID_FILE_ATTRIBUTES)
+        return FALSE;
+
+    basename = strrchrW(pszLinkTo, '\\');
+    if (basename)
+        basename = basename+1;
+    else
+        basename = pszLinkTo;
+
+    lstrcpynW(pszName, pszDir, MAX_PATH);
+    if (!PathAddBackslashW(pszName))
+        return FALSE;
+
+    dst_basename = pszName + strlenW(pszName);
+
+    snprintfW(dst_basename, pszName + MAX_PATH - dst_basename, lnkformat, basename);
+
+    while (GetFileAttributesW(pszName) != INVALID_FILE_ATTRIBUTES)
+    {
+        snprintfW(dst_basename, pszName + MAX_PATH - dst_basename, lnkformatnum, basename, i);
+        i++;
+    }
+
+    return TRUE;
+}
+
 /*************************************************************************
  *              SHStartNetConnectionDialog (SHELL32.@)
  */

Modified: trunk/reactos/include/psdk/shellapi.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/shellapi.h?rev=41308&r1=41307&r2=41308&view=diff
==============================================================================
--- trunk/reactos/include/psdk/shellapi.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/shellapi.h [iso-8859-1] Sat Jun  6 19:45:10 2009
@@ -319,6 +319,18 @@
 #define SHERB_NOPROGRESSUI   0x2
 #define SHERB_NOSOUND        0x4
 
+/******************************************
+ * Links
+ */
+
+#define SHGNLI_PIDL        0x01
+#define SHGNLI_PREFIXNAME  0x02
+#define SHGNLI_NOUNIQUE    0x04
+#define SHGNLI_NOLNK       0x08
+
+BOOL WINAPI SHGetNewLinkInfoA(LPCSTR,LPCSTR,LPSTR,BOOL*,UINT);
+BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR,LPCWSTR,LPWSTR,BOOL*,UINT);
+
 LPWSTR * WINAPI CommandLineToArgvW(LPCWSTR,int*);
 void WINAPI DragAcceptFiles(HWND,BOOL);
 void WINAPI DragFinish(HDROP);
@@ -379,6 +391,7 @@
 #define SHGetNewLinkInfo SHGetNewLinkInfoW
 #define SHQueryRecycleBin SHQueryRecycleBinW
 #define SHEmptyRecycleBin SHEmptyRecycleBinW
+#define SHGetNewLinkInfo SHGetNewLinkInfoW
 
 #else
 #define NOTIFYICONDATA_V1_SIZE NOTIFYICONDATAA_V1_SIZE
@@ -404,6 +417,7 @@
 #define SHGetNewLinkInfo SHGetNewLinkInfoA
 #define SHQueryRecycleBin SHQueryRecycleBinA
 #define SHEmptyRecycleBin SHEmptyRecycleBinA
+#define SHGetNewLinkInfo SHGetNewLinkInfoA
 #endif
 #ifdef __cplusplus
 }



More information about the Ros-diffs mailing list