source: trunk/src/kernel32/disk.cpp@ 1651

Last change on this file since 1651 was 1651, checked in by phaller, 26 years ago

Fix: unicode problems with GetVolumeInformationW

File size: 6.7 KB
Line 
1/* $Id: disk.cpp,v 1.6 1999-11-09 01:22:32 phaller Exp $ */
2
3/*
4 * Win32 Disk API functions for OS/2
5 *
6 * Copyright 1998 Sander van Leeuwen
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12
13
14#include <odin.h>
15#include <odinwrap.h>
16#include <os2sel.h>
17
18#include <os2win.h>
19#include <stdlib.h>
20#include <string.h>
21#include "unicode.h"
22
23
24ODINDEBUGCHANNEL(KERNEL32-DISK)
25
26//******************************************************************************
27//******************************************************************************
28BOOL WIN32API SetVolumeLabelA( LPCSTR arg1, LPCSTR arg2)
29{
30 dprintf(("KERNEL32: OS2SetVolumeLabelA\n"));
31 return O32_SetVolumeLabel(arg1, arg2);
32}
33//******************************************************************************
34//******************************************************************************
35BOOL WIN32API SetVolumeLabelW(LPCWSTR lpRootPathName, LPCWSTR lpVolumeName)
36{
37 char *asciiroot, *asciivolname;
38 BOOL rc;
39
40 dprintf(("KERNEL32: OS2SetVolumeLabelW\n"));
41 asciiroot = UnicodeToAsciiString((LPWSTR)lpRootPathName);
42 asciivolname = UnicodeToAsciiString((LPWSTR)lpVolumeName);
43 rc = O32_SetVolumeLabel(asciiroot, asciivolname);
44 FreeAsciiString(asciivolname);
45 FreeAsciiString(asciiroot);
46 return(rc);
47}
48
49//******************************************************************************
50//SvL: 24-6-'97 - Added
51//******************************************************************************
52BOOL WIN32API GetDiskFreeSpaceA( LPCSTR arg1, PDWORD arg2, PDWORD arg3, PDWORD arg4, PDWORD arg5)
53{
54 dprintf(("KERNEL32: OS2GetDiskFreeSpaceA\n"));
55 return O32_GetDiskFreeSpace(arg1, arg2, arg3, arg4, arg5);
56}
57//******************************************************************************
58//******************************************************************************
59BOOL WIN32API GetDiskFreeSpaceW(LPCWSTR arg1, PDWORD arg2, PDWORD arg3, PDWORD arg4, PDWORD arg5)
60{
61 BOOL rc;
62 char *astring;
63
64 dprintf(("KERNEL32: OS2GetDiskFreeSpaceW\n"));
65 astring = UnicodeToAsciiString((LPWSTR)arg1);
66 rc = O32_GetDiskFreeSpace(astring, arg2, arg3, arg4, arg5);
67 FreeAsciiString(astring);
68 return(rc);
69}
70//******************************************************************************
71//******************************************************************************
72UINT WIN32API GetDriveTypeA( LPCSTR arg1)
73{
74 dprintf(("KERNEL32: GetDriveType %s\n", arg1));
75 return O32_GetDriveType(arg1);
76}
77//******************************************************************************
78//******************************************************************************
79UINT WIN32API GetDriveTypeW(LPCWSTR arg1)
80{
81 UINT rc;
82 char *astring;
83
84 dprintf(("KERNEL32: OS2GetDriveTypeW\n"));
85 astring = UnicodeToAsciiString((LPWSTR)arg1);
86 rc = O32_GetDriveType(astring);
87 FreeAsciiString(astring);
88 return(rc);
89}
90//******************************************************************************
91//******************************************************************************
92ODINFUNCTION8(BOOL, GetVolumeInformationA,
93 LPCSTR, lpRootPathName,
94 LPSTR, lpVolumeNameBuffer,
95 DWORD, nVolumeNameSize,
96 PDWORD, lpVolumeSerialNumber,
97 PDWORD, lpMaximumComponentLength,
98 PDWORD, lpFileSystemFlags,
99 LPSTR, lpFileSystemNameBuffer,
100 DWORD, nFileSystemNameSize)
101{
102 return O32_GetVolumeInformation(lpRootPathName,
103 lpVolumeNameBuffer,
104 nVolumeNameSize,
105 lpVolumeSerialNumber,
106 lpMaximumComponentLength,
107 lpFileSystemFlags,
108 lpFileSystemNameBuffer,
109 nFileSystemNameSize);
110}
111//******************************************************************************
112//******************************************************************************
113
114ODINFUNCTION8(BOOL, GetVolumeInformationW,
115 LPCWSTR, lpRootPathName,
116 LPWSTR, lpVolumeNameBuffer,
117 DWORD, nVolumeNameSize,
118 PDWORD, lpVolumeSerialNumber,
119 PDWORD, lpMaximumComponentLength,
120 PDWORD, lpFileSystemFlags,
121 LPWSTR, lpFileSystemNameBuffer,
122 DWORD, nFileSystemNameSize)
123{
124 char *asciiroot,
125 *asciivol,
126 *asciifs;
127 BOOL rc;
128
129 // transform into ascii
130 asciivol = (char *)malloc(nVolumeNameSize+1);
131 asciifs = (char *)malloc(nFileSystemNameSize+1);
132
133 // clear ascii buffers
134 memset (asciivol, 0, (nVolumeNameSize + 1));
135 memset (asciifs, 0, (nFileSystemNameSize + 1));
136
137 if (lpRootPathName != NULL) // NULL is valid!
138 asciiroot = UnicodeToAsciiString((LPWSTR)lpRootPathName);
139 else
140 asciiroot = NULL;
141
142 // @@@PH switch to ODIN_
143 rc = GetVolumeInformationA(asciiroot,
144 asciivol,
145 nVolumeNameSize,
146 lpVolumeSerialNumber,
147 lpMaximumComponentLength,
148 lpFileSystemFlags,
149 asciifs,
150 nFileSystemNameSize);
151
152 if (lpVolumeNameBuffer != NULL) /* @@@PH 98/06/07 */
153 AsciiToUnicodeN(asciivol, lpVolumeNameBuffer, nVolumeNameSize);
154
155 if (lpFileSystemNameBuffer != NULL) /* @@@PH 98/06/07 */
156 AsciiToUnicodeN(asciifs, lpFileSystemNameBuffer, nFileSystemNameSize);
157
158
159 if (asciiroot != NULL)
160 FreeAsciiString(asciiroot);
161
162 free(asciifs);
163 free(asciivol);
164 return(rc);
165}
166//******************************************************************************
167//******************************************************************************
168DWORD WIN32API GetLogicalDrives(void)
169{
170 dprintf(("KERNEL32: GetLogicalDrives\n"));
171 return O32_GetLogicalDrives();
172}
173//******************************************************************************
174//******************************************************************************
175UINT WIN32API GetLogicalDriveStringsA(UINT arg1, LPSTR arg2)
176{
177 dprintf(("KERNEL32: OS2GetLogicalDriveStringsA\n"));
178 return O32_GetLogicalDriveStrings(arg1, arg2);
179}
180//******************************************************************************
181//******************************************************************************
182UINT WIN32API GetLogicalDriveStringsW(UINT nBufferLength, LPWSTR lpBuffer)
183{
184 char *asciibuffer = (char *)malloc(nBufferLength+1);
185 DWORD rc;
186
187 dprintf(("KERNEL32: OS2GetLogicalDriveStringsW\n"));
188
189 rc = O32_GetLogicalDriveStrings(nBufferLength, asciibuffer);
190 if(rc) AsciiToUnicode(asciibuffer, lpBuffer);
191 free(asciibuffer);
192 return(rc);
193}
Note: See TracBrowser for help on using the repository browser.