From: Eric Kohl Date: Sat, 21 May 2005 12:23:07 +0000 (+0000) Subject: Implement ConcatenatePaths and MyGetFileTitle. X-Git-Tag: backups/xmlbuildsystem@15601~1^2~83 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=4b4c510e04a8fe064fbd46a3799d31ddb8296def Implement ConcatenatePaths and MyGetFileTitle. svn path=/trunk/; revision=15455 --- diff --git a/reactos/include/wine/setupapi.h b/reactos/include/wine/setupapi.h index d7deaa7f21a..ee03767d3cd 100644 --- a/reactos/include/wine/setupapi.h +++ b/reactos/include/wine/setupapi.h @@ -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 *); diff --git a/reactos/lib/setupapi/misc.c b/reactos/lib/setupapi/misc.c index a74ef6f1a47..e5b9b542b10 100644 --- a/reactos/lib/setupapi/misc.c +++ b/reactos/lib/setupapi/misc.c @@ -934,3 +934,113 @@ DWORD WINAPI GetSetFileTimestamp(LPCWSTR lpFileName, return dwError; } + + +/************************************************************************** + * MyGetFileTitle [SETUPAPI.@] + * + * Returns a pointer to the last part of a fully qualified file name. + * + * PARAMS + * lpFileName [I] File name + * + * RETURNS + * Pointer to a files name. + */ +LPWSTR WINAPI +MyGetFileTitle(LPCWSTR lpFileName) +{ + LPWSTR ptr; + LPWSTR ret; + WCHAR c; + + TRACE("%s\n", debugstr_w(lpFileName)); + + ptr = (LPWSTR)lpFileName; + ret = ptr; + while (TRUE) + { + c = *ptr; + + if (c == 0) + break; + + ptr++; + if (c == (WCHAR)'\\' || c == (WCHAR)'/' || c == (WCHAR)':') + ret = ptr; + } + + return ret; +} + + +/************************************************************************** + * ConcatenatePaths [SETUPAPI.@] + * + * Concatenates two paths. + * + * PARAMS + * lpPath [I/O] Path to append path to + * lpAppend [I] Path to append + * dwBufferSize [I] Size of the path buffer + * lpRequiredSize [O] Required size for the concatenated path. Optional + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ +BOOL WINAPI +ConcatenatePaths(LPWSTR lpPath, + LPCWSTR lpAppend, + DWORD dwBufferSize, + LPDWORD lpRequiredSize) +{ + DWORD dwPathSize; + DWORD dwAppendSize; + DWORD dwTotalSize; + BOOL bBackslash = FALSE; + + TRACE("%s %s %lu %p\n", debugstr_w(lpPath), debugstr_w(lpAppend), + dwBufferSize, lpRequiredSize); + + dwPathSize = lstrlenW(lpPath); + + /* Ignore trailing backslash */ + if (lpPath[dwPathSize - 1] == (WCHAR)'\\') + dwPathSize--; + + dwAppendSize = lstrlenW(lpAppend); + + /* Does the source string have a leading backslash? */ + if (lpAppend[0] == (WCHAR)'\\') + { + bBackslash = TRUE; + dwAppendSize--; + } + + dwTotalSize = dwPathSize + dwAppendSize + 2; + if (lpRequiredSize != NULL) + *lpRequiredSize = dwTotalSize; + + /* Append a backslash to the destination string */ + if (bBackslash == FALSE) + { + if (dwPathSize < dwBufferSize) + { + lpPath[dwPathSize - 1] = (WCHAR)'\\'; + dwPathSize++; + } + } + + if (dwPathSize + dwAppendSize < dwBufferSize) + { + lstrcpynW(&lpPath[dwPathSize], + lpAppend, + dwAppendSize); + } + + if (dwBufferSize >= dwTotalSize) + lpPath[dwTotalSize - 1] = 0; + + return (dwBufferSize >= dwTotalSize); +} diff --git a/reactos/lib/setupapi/setupapi.spec b/reactos/lib/setupapi/setupapi.spec index b5a6c867f00..7b172479d72 100644 --- a/reactos/lib/setupapi/setupapi.spec +++ b/reactos/lib/setupapi/setupapi.spec @@ -193,7 +193,7 @@ @ stdcall CaptureAndConvertAnsiArg(str ptr) @ stdcall CaptureStringArg(wstr ptr) @ stub CenterWindowRelativeToParent -@ stub ConcatenatePaths +@ stdcall ConcatenatePaths(wstr wstr long ptr) @ stdcall DelayedMove(wstr wstr) @ stub DelimStringToMultiSz @ stub DestroyTextFileReadBuffer @@ -220,7 +220,7 @@ @ stdcall MultiByteToUnicode(str long) @ stub MultiSzFromSearchControl @ stdcall MyFree(ptr) -@ stub MyGetFileTitle +@ stdcall MyGetFileTitle(wstr) @ stdcall MyMalloc(long) @ stdcall MyRealloc(ptr long) @ stdcall OpenAndMapFileForRead(wstr ptr ptr ptr ptr) @@ -424,8 +424,8 @@ @ stub SetupGetTargetPathW @ stdcall SetupInitDefaultQueueCallback(long) @ stdcall SetupInitDefaultQueueCallbackEx(long long long long ptr) -@ stdcall SetupInitializeFileLogA (str long) -@ stdcall SetupInitializeFileLogW (wstr long) +@ stdcall SetupInitializeFileLogA(str long) +@ stdcall SetupInitializeFileLogW(wstr long) @ stub SetupInstallFileA @ stub SetupInstallFileExA @ stub SetupInstallFileExW