Implement ConcatenatePaths and MyGetFileTitle.

svn path=/trunk/; revision=15455
This commit is contained in:
Eric Kohl 2005-05-21 12:23:07 +00:00
parent 385055dd76
commit 4b4c510e04
3 changed files with 116 additions and 4 deletions

View 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 *);

View file

@ -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);
}

View file

@ -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