1 | /* $Id: disk.cpp,v 1.10 2000-03-28 17:24:27 sandervl 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 | #define DBG_LOCALLOG DBG_disk
|
---|
24 | #include "dbglocal.h"
|
---|
25 |
|
---|
26 |
|
---|
27 | ODINDEBUGCHANNEL(KERNEL32-DISK)
|
---|
28 |
|
---|
29 | //******************************************************************************
|
---|
30 | //******************************************************************************
|
---|
31 | BOOL WIN32API SetVolumeLabelA( LPCSTR arg1, LPCSTR arg2)
|
---|
32 | {
|
---|
33 | dprintf(("KERNEL32: OS2SetVolumeLabelA\n"));
|
---|
34 | return O32_SetVolumeLabel(arg1, arg2);
|
---|
35 | }
|
---|
36 | //******************************************************************************
|
---|
37 | //******************************************************************************
|
---|
38 | BOOL WIN32API SetVolumeLabelW(LPCWSTR lpRootPathName, LPCWSTR lpVolumeName)
|
---|
39 | {
|
---|
40 | char *asciiroot, *asciivolname;
|
---|
41 | BOOL rc;
|
---|
42 |
|
---|
43 | dprintf(("KERNEL32: OS2SetVolumeLabelW\n"));
|
---|
44 | asciiroot = UnicodeToAsciiString((LPWSTR)lpRootPathName);
|
---|
45 | asciivolname = UnicodeToAsciiString((LPWSTR)lpVolumeName);
|
---|
46 | rc = O32_SetVolumeLabel(asciiroot, asciivolname);
|
---|
47 | FreeAsciiString(asciivolname);
|
---|
48 | FreeAsciiString(asciiroot);
|
---|
49 | return(rc);
|
---|
50 | }
|
---|
51 |
|
---|
52 | //******************************************************************************
|
---|
53 | //SvL: 24-6-'97 - Added
|
---|
54 | //******************************************************************************
|
---|
55 | BOOL WIN32API GetDiskFreeSpaceA( LPCSTR arg1, PDWORD arg2, PDWORD arg3, PDWORD arg4, PDWORD arg5)
|
---|
56 | {
|
---|
57 | BOOL rc;
|
---|
58 | DWORD dwSectorsPerCluster; // address of sectors per cluster ter
|
---|
59 | DWORD dwBytesPerSector; // address of bytes per sector
|
---|
60 | DWORD dwNumberOfFreeClusters; // address of number of free clusters
|
---|
61 | DWORD dwTotalNumberOfClusters; // address of total number of clusters
|
---|
62 | dprintf(("KERNEL32: OS2GetDiskFreeSpaceA %s, 0x%08X, 0x%08X, 0x%08X, 0x%08X,\n",
|
---|
63 | arg1!=NULL?arg1:"NULL", arg2,arg3,arg4,arg5));
|
---|
64 | rc = O32_GetDiskFreeSpace(arg1, &dwSectorsPerCluster, &dwBytesPerSector,
|
---|
65 | &dwNumberOfFreeClusters, &dwTotalNumberOfClusters);
|
---|
66 | if(rc)
|
---|
67 | {
|
---|
68 | if (arg2!=NULL)
|
---|
69 | *arg2 = dwSectorsPerCluster;
|
---|
70 | if (arg3!=NULL)
|
---|
71 | *arg3 = dwBytesPerSector;
|
---|
72 | if (arg4!=NULL)
|
---|
73 | *arg4 = dwNumberOfFreeClusters;
|
---|
74 | if (arg5!=NULL)
|
---|
75 | *arg5 = dwTotalNumberOfClusters;
|
---|
76 | }
|
---|
77 | dprintf((" returned %d\n",rc));
|
---|
78 | return rc;
|
---|
79 | }
|
---|
80 | //******************************************************************************
|
---|
81 | //******************************************************************************
|
---|
82 | BOOL WIN32API GetDiskFreeSpaceW(LPCWSTR arg1, PDWORD arg2, PDWORD arg3, PDWORD arg4, PDWORD arg5)
|
---|
83 | {
|
---|
84 | BOOL rc;
|
---|
85 | char *astring;
|
---|
86 |
|
---|
87 | dprintf(("KERNEL32: OS2GetDiskFreeSpaceW\n"));
|
---|
88 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
89 | rc = O32_GetDiskFreeSpace(astring, arg2, arg3, arg4, arg5);
|
---|
90 | FreeAsciiString(astring);
|
---|
91 | return(rc);
|
---|
92 | }
|
---|
93 |
|
---|
94 |
|
---|
95 | /*****************************************************************************
|
---|
96 | * Name : GetDiskFreeSpaceEx
|
---|
97 | * Purpose :
|
---|
98 | * Parameters: lpDirectoryName [in] Pointer to a null-terminated string that
|
---|
99 | * specifies a directory on the disk of interest.
|
---|
100 | * This string can be a UNC name. If this
|
---|
101 | * parameter is a UNC name, you must follow it
|
---|
102 | * with an additional backslash. For example, you
|
---|
103 | * would specify \\MyServer\MyShare as
|
---|
104 | * \\MyServer\MyShare\.
|
---|
105 | * If lpDirectoryName is NULL, the
|
---|
106 | * GetDiskFreeSpaceEx function obtains
|
---|
107 | * information about the object store.
|
---|
108 | * Note that lpDirectoryName does not have to
|
---|
109 | * specify the root directory on a disk. The
|
---|
110 | * function accepts any directory on the disk.
|
---|
111 | *
|
---|
112 | * lpFreeBytesAvailableToCaller
|
---|
113 | * [out] Pointer to a variable to receive the
|
---|
114 | * total number of free bytes on the disk that
|
---|
115 | * are available to the user associated with the
|
---|
116 | * calling thread.
|
---|
117 | * lpTotalNumberOfBytes
|
---|
118 | * [out] Pointer to a variable to receive the
|
---|
119 | * total number of bytes on the disk that are
|
---|
120 | * available to the user associated with the
|
---|
121 | * calling thread.
|
---|
122 | * lpTotalNumberOfFreeBytes
|
---|
123 | * [out] Pointer to a variable to receive the
|
---|
124 | * total number of free bytes on the disk.
|
---|
125 | * This parameter can be NULL.
|
---|
126 | * Variables :
|
---|
127 | * Result : Nonzero indicates success. Zero indicates failure. To get
|
---|
128 | * extended error information, call GetLastError.
|
---|
129 | * Remark : Note that the values obtained by this function are of type
|
---|
130 | * ULARGE_INTEGER. Be careful not to truncate these values to
|
---|
131 | * 32 bits.
|
---|
132 | * Status :
|
---|
133 | *
|
---|
134 | * Author : Patrick Haller [Fri, 2000/01/08 23:44]
|
---|
135 | *****************************************************************************/
|
---|
136 |
|
---|
137 | ODINFUNCTION4(BOOL,GetDiskFreeSpaceExA,
|
---|
138 | LPCSTR, lpDirectoryName,
|
---|
139 | PULARGE_INTEGER, lpFreeBytesAvailableToCaller,
|
---|
140 | PULARGE_INTEGER, lpTotalNumberOfBytes,
|
---|
141 | PULARGE_INTEGER, lpTotalNumberOfFreeBytes )
|
---|
142 | {
|
---|
143 | dprintf(("not yet implemented"));
|
---|
144 |
|
---|
145 | return TRUE;
|
---|
146 | }
|
---|
147 |
|
---|
148 |
|
---|
149 | ODINFUNCTION4(BOOL,GetDiskFreeSpaceExW,
|
---|
150 | LPCWSTR, lpDirectoryName,
|
---|
151 | PULARGE_INTEGER, lpFreeBytesAvailableToCaller,
|
---|
152 | PULARGE_INTEGER, lpTotalNumberOfBytes,
|
---|
153 | PULARGE_INTEGER, lpTotalNumberOfFreeBytes )
|
---|
154 | {
|
---|
155 | dprintf(("not yet implemented"));
|
---|
156 |
|
---|
157 | return TRUE;
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 | //******************************************************************************
|
---|
162 | //******************************************************************************
|
---|
163 | UINT WIN32API GetDriveTypeA( LPCSTR arg1)
|
---|
164 | {
|
---|
165 | UINT rc;
|
---|
166 | rc = O32_GetDriveType(arg1);
|
---|
167 | dprintf(("KERNEL32: GetDriveType %s = %d\n", arg1,rc));
|
---|
168 | return rc;
|
---|
169 | }
|
---|
170 | //******************************************************************************
|
---|
171 | //******************************************************************************
|
---|
172 | UINT WIN32API GetDriveTypeW(LPCWSTR arg1)
|
---|
173 | {
|
---|
174 | UINT rc;
|
---|
175 | char *astring;
|
---|
176 |
|
---|
177 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
178 | dprintf(("KERNEL32: OS2GetDriveTypeW %s", astring));
|
---|
179 | rc = O32_GetDriveType(astring);
|
---|
180 | FreeAsciiString(astring);
|
---|
181 | return(rc);
|
---|
182 | }
|
---|
183 | //******************************************************************************
|
---|
184 | //******************************************************************************
|
---|
185 | ODINFUNCTION8(BOOL, GetVolumeInformationA,
|
---|
186 | LPCSTR, lpRootPathName,
|
---|
187 | LPSTR, lpVolumeNameBuffer,
|
---|
188 | DWORD, nVolumeNameSize,
|
---|
189 | PDWORD, lpVolumeSerialNumber,
|
---|
190 | PDWORD, lpMaximumComponentLength,
|
---|
191 | PDWORD, lpFileSystemFlags,
|
---|
192 | LPSTR, lpFileSystemNameBuffer,
|
---|
193 | DWORD, nFileSystemNameSize)
|
---|
194 | {
|
---|
195 | dprintf(("GetVolumeInformationA %s", lpRootPathName));
|
---|
196 | return O32_GetVolumeInformation(lpRootPathName,
|
---|
197 | lpVolumeNameBuffer,
|
---|
198 | nVolumeNameSize,
|
---|
199 | lpVolumeSerialNumber,
|
---|
200 | lpMaximumComponentLength,
|
---|
201 | lpFileSystemFlags,
|
---|
202 | lpFileSystemNameBuffer,
|
---|
203 | nFileSystemNameSize);
|
---|
204 | }
|
---|
205 | //******************************************************************************
|
---|
206 | //******************************************************************************
|
---|
207 |
|
---|
208 | ODINFUNCTION8(BOOL, GetVolumeInformationW,
|
---|
209 | LPCWSTR, lpRootPathName,
|
---|
210 | LPWSTR, lpVolumeNameBuffer,
|
---|
211 | DWORD, nVolumeNameSize,
|
---|
212 | PDWORD, lpVolumeSerialNumber,
|
---|
213 | PDWORD, lpMaximumComponentLength,
|
---|
214 | PDWORD, lpFileSystemFlags,
|
---|
215 | LPWSTR, lpFileSystemNameBuffer,
|
---|
216 | DWORD, nFileSystemNameSize)
|
---|
217 | {
|
---|
218 | char *asciiroot,
|
---|
219 | *asciivol,
|
---|
220 | *asciifs;
|
---|
221 | BOOL rc;
|
---|
222 |
|
---|
223 | // transform into ascii
|
---|
224 | asciivol = (char *)malloc(nVolumeNameSize+1);
|
---|
225 | asciifs = (char *)malloc(nFileSystemNameSize+1);
|
---|
226 |
|
---|
227 | // clear ascii buffers
|
---|
228 | memset (asciivol, 0, (nVolumeNameSize + 1));
|
---|
229 | memset (asciifs, 0, (nFileSystemNameSize + 1));
|
---|
230 |
|
---|
231 | if (lpRootPathName != NULL) // NULL is valid!
|
---|
232 | asciiroot = UnicodeToAsciiString((LPWSTR)lpRootPathName);
|
---|
233 | else
|
---|
234 | asciiroot = NULL;
|
---|
235 |
|
---|
236 | // @@@PH switch to ODIN_
|
---|
237 | rc = GetVolumeInformationA(asciiroot,
|
---|
238 | asciivol,
|
---|
239 | nVolumeNameSize,
|
---|
240 | lpVolumeSerialNumber,
|
---|
241 | lpMaximumComponentLength,
|
---|
242 | lpFileSystemFlags,
|
---|
243 | asciifs,
|
---|
244 | nFileSystemNameSize);
|
---|
245 |
|
---|
246 | if (lpVolumeNameBuffer != NULL) /* @@@PH 98/06/07 */
|
---|
247 | AsciiToUnicodeN(asciivol, lpVolumeNameBuffer, nVolumeNameSize);
|
---|
248 |
|
---|
249 | if (lpFileSystemNameBuffer != NULL) /* @@@PH 98/06/07 */
|
---|
250 | AsciiToUnicodeN(asciifs, lpFileSystemNameBuffer, nFileSystemNameSize);
|
---|
251 |
|
---|
252 |
|
---|
253 | if (asciiroot != NULL)
|
---|
254 | FreeAsciiString(asciiroot);
|
---|
255 |
|
---|
256 | free(asciifs);
|
---|
257 | free(asciivol);
|
---|
258 | return(rc);
|
---|
259 | }
|
---|
260 | //******************************************************************************
|
---|
261 | //******************************************************************************
|
---|
262 | DWORD WIN32API GetLogicalDrives(void)
|
---|
263 | {
|
---|
264 | dprintf(("KERNEL32: GetLogicalDrives\n"));
|
---|
265 | return O32_GetLogicalDrives();
|
---|
266 | }
|
---|
267 | //******************************************************************************
|
---|
268 | //******************************************************************************
|
---|
269 | UINT WIN32API GetLogicalDriveStringsA(UINT arg1, LPSTR arg2)
|
---|
270 | {
|
---|
271 | dprintf(("KERNEL32: OS2GetLogicalDriveStringsA\n"));
|
---|
272 | return O32_GetLogicalDriveStrings(arg1, arg2);
|
---|
273 | }
|
---|
274 | //******************************************************************************
|
---|
275 | //******************************************************************************
|
---|
276 | UINT WIN32API GetLogicalDriveStringsW(UINT nBufferLength, LPWSTR lpBuffer)
|
---|
277 | {
|
---|
278 | char *asciibuffer = (char *)malloc(nBufferLength+1);
|
---|
279 | DWORD rc;
|
---|
280 |
|
---|
281 | dprintf(("KERNEL32: OS2GetLogicalDriveStringsW\n"));
|
---|
282 |
|
---|
283 | rc = O32_GetLogicalDriveStrings(nBufferLength, asciibuffer);
|
---|
284 | if(rc) AsciiToUnicode(asciibuffer, lpBuffer);
|
---|
285 | free(asciibuffer);
|
---|
286 | return(rc);
|
---|
287 | }
|
---|