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