Ignore:
Timestamp:
Nov 9, 1999, 2:22:32 AM (26 years ago)
Author:
phaller
Message:

Fix: unicode problems with GetVolumeInformationW

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/disk.cpp

    r682 r1651  
    1 /* $Id: disk.cpp,v 1.5 1999-08-25 11:25:47 sandervl Exp $ */
     1/* $Id: disk.cpp,v 1.6 1999-11-09 01:22:32 phaller Exp $ */
    22
    33/*
     
    1010 *
    1111 */
     12
     13
     14#include <odin.h>
     15#include <odinwrap.h>
     16#include <os2sel.h>
     17
    1218#include <os2win.h>
    1319#include <stdlib.h>
     20#include <string.h>
    1421#include "unicode.h"
     22
     23
     24ODINDEBUGCHANNEL(KERNEL32-DISK)
    1525
    1626//******************************************************************************
     
    8090//******************************************************************************
    8191//******************************************************************************
    82 BOOL WIN32API GetVolumeInformationA(LPCSTR arg1, LPSTR arg2, DWORD arg3, PDWORD arg4,
    83                                     PDWORD arg5, PDWORD arg6, LPSTR arg7, DWORD  arg8)
     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)
    84101{
    85     dprintf(("KERNEL32:  GetVolumeInformation %s %s\n", arg1, arg2));
    86     return O32_GetVolumeInformation(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
     102   return O32_GetVolumeInformation(lpRootPathName,
     103                                   lpVolumeNameBuffer,
     104                                   nVolumeNameSize,
     105                                   lpVolumeSerialNumber,
     106                                   lpMaximumComponentLength,
     107                                   lpFileSystemFlags,
     108                                   lpFileSystemNameBuffer,
     109                                   nFileSystemNameSize);
    87110}
    88111//******************************************************************************
    89112//******************************************************************************
    90 BOOL WIN32API GetVolumeInformationW(LPCWSTR arg1, LPWSTR arg2, DWORD arg3,
    91                                     PDWORD arg4, PDWORD arg5, PDWORD arg6,
    92                                     LPWSTR arg7, DWORD  arg8)
     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)
    93123{
    94  char *asciiroot, *asciivol, *asciifs;
    95  BOOL  rc;
     124  char *asciiroot,
     125       *asciivol,
     126       *asciifs;
     127  BOOL  rc;
    96128
    97     dprintf(("KERNEL32:  OS2GetVolumeInformationW\n"));
    98     asciivol  = (char *)malloc(arg3+1);
    99     asciifs   = (char *)malloc(arg8+1);
    100     asciiroot = UnicodeToAsciiString((LPWSTR)arg1);
    101     rc = O32_GetVolumeInformation(asciiroot, asciivol, arg3, arg4, arg5, arg6, asciifs, arg8);
     129  // transform into ascii
     130  asciivol  = (char *)malloc(nVolumeNameSize+1);
     131  asciifs   = (char *)malloc(nFileSystemNameSize+1);
    102132
    103     if (arg2 != NULL)  /* @@@PH 98/06/07 */
    104       AsciiToUnicode(asciivol, arg2);
     133  // clear ascii buffers
     134  memset (asciivol, 0, (nVolumeNameSize + 1));
     135  memset (asciifs,  0, (nFileSystemNameSize + 1));
    105136
    106     if (arg7 != NULL)  /* @@@PH 98/06/07 */
    107       AsciiToUnicode(asciifs, arg7);
     137  if (lpRootPathName != NULL) // NULL is valid!
     138    asciiroot = UnicodeToAsciiString((LPWSTR)lpRootPathName);
     139  else
     140    asciiroot = NULL;
    108141
     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)
    109160    FreeAsciiString(asciiroot);
    110     free(asciifs);
    111     free(asciivol);
    112     return(rc);
     161
     162  free(asciifs);
     163  free(asciivol);
     164  return(rc);
    113165}
    114166//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.