ReactOS 0.4.16-dev-2274-gc61d98f
volumeansi.c File Reference
#include <k32.h>
Include dependency graph for volumeansi.c:

Go to the source code of this file.

Functions

BOOL WINAPI GetVolumePathNameA (IN LPCSTR lpszFileName, IN LPSTR lpszVolumePathName, IN DWORD cchBufferLength)
 

Function Documentation

◆ GetVolumePathNameA()

BOOL WINAPI GetVolumePathNameA ( IN LPCSTR  lpszFileName,
IN LPSTR  lpszVolumePathName,
IN DWORD  cchBufferLength 
)

Definition at line 19 of file volumeansi.c.

22{
23 BOOL Ret;
24 PUNICODE_STRING FileNameU;
25 ANSI_STRING VolumePathName;
26 UNICODE_STRING VolumePathNameU;
27
28 /* Convert file name to unicode */
29 FileNameU = Basep8BitStringToStaticUnicodeString(lpszFileName);
30 if (FileNameU == NULL)
31 {
32 return FALSE;
33 }
34
35 /* Initialize all the strings we'll need */
36 VolumePathName.Buffer = lpszVolumePathName;
37 VolumePathName.Length = 0;
38 VolumePathName.MaximumLength = cchBufferLength - 1;
39
40 VolumePathNameU.Length = 0;
41 VolumePathNameU.MaximumLength = (cchBufferLength - 1) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
42 /* Allocate a buffer for calling the -W */
43 VolumePathNameU.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, VolumePathNameU.MaximumLength);
44 if (VolumePathNameU.Buffer == NULL)
45 {
47 return FALSE;
48 }
49
50 /* Call the -W implementation */
51 Ret = GetVolumePathNameW(FileNameU->Buffer, VolumePathNameU.Buffer, cchBufferLength);
52 /* If it succeed */
53 if (Ret)
54 {
56
57 /* Convert back to ANSI */
58 RtlInitUnicodeString(&VolumePathNameU, VolumePathNameU.Buffer);
59 Status = RtlUnicodeStringToAnsiString(&VolumePathName, &VolumePathNameU, FALSE);
60 /* If conversion failed, just set error code and fail the rest */
61 if (!NT_SUCCESS(Status))
62 {
64 Ret = FALSE;
65 }
66 /* Otherwise, null terminate the string (it's OK, we computed -1) */
67 else
68 {
69 VolumePathName.Buffer[VolumePathName.Length] = ANSI_NULL;
70 }
71 }
72
73 /* Free the buffer allocated for -W call */
74 RtlFreeHeap(RtlGetProcessHeap(), 0, VolumePathNameU.Buffer);
75 return Ret;
76}
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define SetLastError(x)
Definition: compat.h:752
BOOL WINAPI GetVolumePathNameW(IN LPCWSTR lpszFileName, IN LPWSTR lpszVolumePathName, IN DWORD cchBufferLength)
Definition: volume.c:751
PUNICODE_STRING WINAPI Basep8BitStringToStaticUnicodeString(IN LPCSTR String)
Definition: utils.c:189
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_NULL
#define ANSI_NULL
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:167
USHORT MaximumLength
Definition: env_spec_w32.h:377
USHORT MaximumLength
Definition: env_spec_w32.h:370
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_GetVolumePathNameA(), and test_mounted_folder().