| 1 | /* $Id: disk.cpp,v 1.7 1999-11-11 19:10:09 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 |
|
|---|
| 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 | UINT WIN32API GetDriveTypeA( LPCSTR arg1)
|
|---|
| 73 | {
|
|---|
| 74 | dprintf(("KERNEL32: GetDriveType %s\n", arg1));
|
|---|
| 75 | return O32_GetDriveType(arg1);
|
|---|
| 76 | }
|
|---|
| 77 | //******************************************************************************
|
|---|
| 78 | //******************************************************************************
|
|---|
| 79 | UINT WIN32API GetDriveTypeW(LPCWSTR arg1)
|
|---|
| 80 | {
|
|---|
| 81 | UINT rc;
|
|---|
| 82 | char *astring;
|
|---|
| 83 |
|
|---|
| 84 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 85 | dprintf(("KERNEL32: OS2GetDriveTypeW %s", astring));
|
|---|
| 86 | rc = O32_GetDriveType(astring);
|
|---|
| 87 | FreeAsciiString(astring);
|
|---|
| 88 | return(rc);
|
|---|
| 89 | }
|
|---|
| 90 | //******************************************************************************
|
|---|
| 91 | //******************************************************************************
|
|---|
| 92 | ODINFUNCTION8(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 | dprintf(("GetVolumeInformationA %s", lpRootPathName));
|
|---|
| 103 | return O32_GetVolumeInformation(lpRootPathName,
|
|---|
| 104 | lpVolumeNameBuffer,
|
|---|
| 105 | nVolumeNameSize,
|
|---|
| 106 | lpVolumeSerialNumber,
|
|---|
| 107 | lpMaximumComponentLength,
|
|---|
| 108 | lpFileSystemFlags,
|
|---|
| 109 | lpFileSystemNameBuffer,
|
|---|
| 110 | nFileSystemNameSize);
|
|---|
| 111 | }
|
|---|
| 112 | //******************************************************************************
|
|---|
| 113 | //******************************************************************************
|
|---|
| 114 |
|
|---|
| 115 | ODINFUNCTION8(BOOL, GetVolumeInformationW,
|
|---|
| 116 | LPCWSTR, lpRootPathName,
|
|---|
| 117 | LPWSTR, lpVolumeNameBuffer,
|
|---|
| 118 | DWORD, nVolumeNameSize,
|
|---|
| 119 | PDWORD, lpVolumeSerialNumber,
|
|---|
| 120 | PDWORD, lpMaximumComponentLength,
|
|---|
| 121 | PDWORD, lpFileSystemFlags,
|
|---|
| 122 | LPWSTR, lpFileSystemNameBuffer,
|
|---|
| 123 | DWORD, nFileSystemNameSize)
|
|---|
| 124 | {
|
|---|
| 125 | char *asciiroot,
|
|---|
| 126 | *asciivol,
|
|---|
| 127 | *asciifs;
|
|---|
| 128 | BOOL rc;
|
|---|
| 129 |
|
|---|
| 130 | // transform into ascii
|
|---|
| 131 | asciivol = (char *)malloc(nVolumeNameSize+1);
|
|---|
| 132 | asciifs = (char *)malloc(nFileSystemNameSize+1);
|
|---|
| 133 |
|
|---|
| 134 | // clear ascii buffers
|
|---|
| 135 | memset (asciivol, 0, (nVolumeNameSize + 1));
|
|---|
| 136 | memset (asciifs, 0, (nFileSystemNameSize + 1));
|
|---|
| 137 |
|
|---|
| 138 | if (lpRootPathName != NULL) // NULL is valid!
|
|---|
| 139 | asciiroot = UnicodeToAsciiString((LPWSTR)lpRootPathName);
|
|---|
| 140 | else
|
|---|
| 141 | asciiroot = NULL;
|
|---|
| 142 |
|
|---|
| 143 | // @@@PH switch to ODIN_
|
|---|
| 144 | rc = GetVolumeInformationA(asciiroot,
|
|---|
| 145 | asciivol,
|
|---|
| 146 | nVolumeNameSize,
|
|---|
| 147 | lpVolumeSerialNumber,
|
|---|
| 148 | lpMaximumComponentLength,
|
|---|
| 149 | lpFileSystemFlags,
|
|---|
| 150 | asciifs,
|
|---|
| 151 | nFileSystemNameSize);
|
|---|
| 152 |
|
|---|
| 153 | if (lpVolumeNameBuffer != NULL) /* @@@PH 98/06/07 */
|
|---|
| 154 | AsciiToUnicodeN(asciivol, lpVolumeNameBuffer, nVolumeNameSize);
|
|---|
| 155 |
|
|---|
| 156 | if (lpFileSystemNameBuffer != NULL) /* @@@PH 98/06/07 */
|
|---|
| 157 | AsciiToUnicodeN(asciifs, lpFileSystemNameBuffer, nFileSystemNameSize);
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | if (asciiroot != NULL)
|
|---|
| 161 | FreeAsciiString(asciiroot);
|
|---|
| 162 |
|
|---|
| 163 | free(asciifs);
|
|---|
| 164 | free(asciivol);
|
|---|
| 165 | return(rc);
|
|---|
| 166 | }
|
|---|
| 167 | //******************************************************************************
|
|---|
| 168 | //******************************************************************************
|
|---|
| 169 | DWORD WIN32API GetLogicalDrives(void)
|
|---|
| 170 | {
|
|---|
| 171 | dprintf(("KERNEL32: GetLogicalDrives\n"));
|
|---|
| 172 | return O32_GetLogicalDrives();
|
|---|
| 173 | }
|
|---|
| 174 | //******************************************************************************
|
|---|
| 175 | //******************************************************************************
|
|---|
| 176 | UINT WIN32API GetLogicalDriveStringsA(UINT arg1, LPSTR arg2)
|
|---|
| 177 | {
|
|---|
| 178 | dprintf(("KERNEL32: OS2GetLogicalDriveStringsA\n"));
|
|---|
| 179 | return O32_GetLogicalDriveStrings(arg1, arg2);
|
|---|
| 180 | }
|
|---|
| 181 | //******************************************************************************
|
|---|
| 182 | //******************************************************************************
|
|---|
| 183 | UINT WIN32API GetLogicalDriveStringsW(UINT nBufferLength, LPWSTR lpBuffer)
|
|---|
| 184 | {
|
|---|
| 185 | char *asciibuffer = (char *)malloc(nBufferLength+1);
|
|---|
| 186 | DWORD rc;
|
|---|
| 187 |
|
|---|
| 188 | dprintf(("KERNEL32: OS2GetLogicalDriveStringsW\n"));
|
|---|
| 189 |
|
|---|
| 190 | rc = O32_GetLogicalDriveStrings(nBufferLength, asciibuffer);
|
|---|
| 191 | if(rc) AsciiToUnicode(asciibuffer, lpBuffer);
|
|---|
| 192 | free(asciibuffer);
|
|---|
| 193 | return(rc);
|
|---|
| 194 | }
|
|---|