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