Implement ConcatenatePaths and MyGetFileTitle.
authorEric Kohl <eric.kohl@reactos.org>
Sat, 21 May 2005 12:23:07 +0000 (12:23 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 21 May 2005 12:23:07 +0000 (12:23 +0000)
svn path=/trunk/; revision=15455

reactos/include/wine/setupapi.h
reactos/lib/setupapi/misc.c
reactos/lib/setupapi/setupapi.spec

index d7deaa7..ee03767 100644 (file)
@@ -669,6 +669,7 @@ LONG     WINAPI AddTagToGroupOrderList(PCWSTR lpGroupName, DWORD dwUnknown2, DWO
 VOID     WINAPI AssertFail(LPSTR, UINT, LPSTR);
 DWORD    WINAPI CaptureAndConvertAnsiArg(PCSTR lpSrc, PWSTR *lpDst);
 DWORD    WINAPI CaptureStringArg(PCWSTR lpSrc, PWSTR *lpDst);
+BOOL     WINAPI ConcatenatePaths(LPWSTR, LPCWSTR, DWORD, LPDWORD);
 BOOL     WINAPI DelayedMove(PCWSTR lpExistingFileName, PCWSTR lpNewFileName);
 BOOL     WINAPI DoesUserHavePrivilege(PCWSTR lpPrivilegeName);
 PWSTR    WINAPI DuplicateString(PCWSTR lpSrc);
@@ -681,6 +682,7 @@ void     WINAPI InstallHinfSectionW( HWND hwnd, HINSTANCE handle, PCWSTR cmdline
 BOOL     WINAPI IsUserAdmin(VOID);
 PWSTR    WINAPI MultiByteToUnicode(PCSTR lpMultiByteStr, UINT uCodePage);
 VOID     WINAPI MyFree(PVOID lpMem);
+PWSTR    WINAPI MyGetFileTitle(PCWSTR);
 PVOID    WINAPI MyMalloc(DWORD dwSize);
 PVOID    WINAPI MyRealloc(PVOID lpSrc, DWORD dwSize);
 DWORD    WINAPI OpenAndMapForRead(PCWSTR, PDWORD, PHANDLE, PHANDLE, PVOID *);
index a74ef6f..e5b9b54 100644 (file)
@@ -934,3 +934,113 @@ DWORD WINAPI GetSetFileTimestamp(LPCWSTR lpFileName,
 \r
      return dwError;\r
 }\r
+\r
+\r
+/**************************************************************************\r
+ * MyGetFileTitle [SETUPAPI.@]\r
+ *\r
+ * Returns a pointer to the last part of a fully qualified file name.\r
+ *\r
+ * PARAMS\r
+ *     lpFileName [I] File name\r
+ *\r
+ * RETURNS\r
+ *     Pointer to a files name.\r
+ */\r
+LPWSTR WINAPI\r
+MyGetFileTitle(LPCWSTR lpFileName)\r
+{\r
+    LPWSTR ptr;\r
+    LPWSTR ret;\r
+    WCHAR c;\r
+\r
+    TRACE("%s\n", debugstr_w(lpFileName));\r
+\r
+    ptr = (LPWSTR)lpFileName;\r
+    ret = ptr;\r
+    while (TRUE)\r
+    {\r
+        c = *ptr;\r
+\r
+        if (c == 0)\r
+            break;\r
+\r
+        ptr++;\r
+        if (c == (WCHAR)'\\' || c == (WCHAR)'/' || c == (WCHAR)':')\r
+            ret = ptr;\r
+    }\r
+\r
+    return ret;\r
+}\r
+\r
+\r
+/**************************************************************************\r
+ * ConcatenatePaths [SETUPAPI.@]\r
+ *\r
+ * Concatenates two paths.\r
+ *\r
+ * PARAMS\r
+ *     lpPath         [I/O] Path to append path to\r
+ *     lpAppend       [I]   Path to append\r
+ *     dwBufferSize   [I]   Size of the path buffer\r
+ *     lpRequiredSize [O]   Required size for the concatenated path. Optional\r
+ *\r
+ * RETURNS\r
+ *     Success: TRUE\r
+ *     Failure: FALSE\r
+ */\r
+BOOL WINAPI\r
+ConcatenatePaths(LPWSTR lpPath,\r
+                 LPCWSTR lpAppend,\r
+                 DWORD dwBufferSize,\r
+                 LPDWORD lpRequiredSize)\r
+{\r
+    DWORD dwPathSize;\r
+    DWORD dwAppendSize;\r
+    DWORD dwTotalSize;\r
+    BOOL bBackslash = FALSE;\r
+\r
+    TRACE("%s %s %lu %p\n", debugstr_w(lpPath), debugstr_w(lpAppend),\r
+          dwBufferSize, lpRequiredSize);\r
+\r
+    dwPathSize = lstrlenW(lpPath);\r
+\r
+    /* Ignore trailing backslash */\r
+    if (lpPath[dwPathSize - 1] == (WCHAR)'\\')\r
+        dwPathSize--;\r
+\r
+    dwAppendSize = lstrlenW(lpAppend);\r
+\r
+    /* Does the source string have a leading backslash? */\r
+    if (lpAppend[0] == (WCHAR)'\\')\r
+    {\r
+        bBackslash = TRUE;\r
+        dwAppendSize--;\r
+    }\r
+\r
+    dwTotalSize = dwPathSize + dwAppendSize + 2;\r
+    if (lpRequiredSize != NULL)\r
+        *lpRequiredSize = dwTotalSize;\r
+\r
+    /* Append a backslash to the destination string */\r
+    if (bBackslash == FALSE)\r
+    {\r
+        if (dwPathSize < dwBufferSize)\r
+        {\r
+            lpPath[dwPathSize - 1] = (WCHAR)'\\';\r
+            dwPathSize++;\r
+        }\r
+    }\r
+\r
+    if (dwPathSize + dwAppendSize < dwBufferSize)\r
+    {\r
+        lstrcpynW(&lpPath[dwPathSize],\r
+                  lpAppend,\r
+                  dwAppendSize);\r
+    }\r
+\r
+    if (dwBufferSize >= dwTotalSize)\r
+        lpPath[dwTotalSize - 1] = 0;\r
+\r
+    return (dwBufferSize >= dwTotalSize);\r
+}\r
index b5a6c86..7b17247 100644 (file)
 @ stdcall CaptureAndConvertAnsiArg(str ptr)\r
 @ stdcall CaptureStringArg(wstr ptr)\r
 @ stub CenterWindowRelativeToParent\r
-@ stub ConcatenatePaths\r
+@ stdcall ConcatenatePaths(wstr wstr long ptr)\r
 @ stdcall DelayedMove(wstr wstr)\r
 @ stub DelimStringToMultiSz\r
 @ stub DestroyTextFileReadBuffer\r
 @ stdcall MultiByteToUnicode(str long)\r
 @ stub MultiSzFromSearchControl\r
 @ stdcall MyFree(ptr)\r
-@ stub MyGetFileTitle\r
+@ stdcall MyGetFileTitle(wstr)\r
 @ stdcall MyMalloc(long)\r
 @ stdcall MyRealloc(ptr long)\r
 @ stdcall OpenAndMapFileForRead(wstr ptr ptr ptr ptr)\r
 @ stub SetupGetTargetPathW\r
 @ stdcall SetupInitDefaultQueueCallback(long)\r
 @ stdcall SetupInitDefaultQueueCallbackEx(long long long long ptr)\r
-@ stdcall SetupInitializeFileLogA (str long)\r
-@ stdcall SetupInitializeFileLogW (wstr long)\r
+@ stdcall SetupInitializeFileLogA(str long)\r
+@ stdcall SetupInitializeFileLogW(wstr long)\r
 @ stub SetupInstallFileA\r
 @ stub SetupInstallFileExA\r
 @ stub SetupInstallFileExW\r