Ignore:
Timestamp:
May 14, 2002, 11:28:19 AM (23 years ago)
Author:
sandervl
Message:

CustForce2GBFileSize function added to force GetVolumeInformation to tell the app all partitions are FAT

File:
1 edited

Legend:

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

    r8401 r8409  
    1 /* $Id: disk.cpp,v 1.36 2002-05-10 14:55:10 sandervl Exp $ */
     1/* $Id: disk.cpp,v 1.37 2002-05-14 09:28:19 sandervl Exp $ */
    22
    33/*
    44 * Win32 Disk API functions for OS/2
    55 *
    6  * Copyright 1998 Sander van Leeuwen
     6 * Copyright 1998-2002 Sander van Leeuwen
    77 *
    88 *
     
    4646BOOL WIN32API SetVolumeLabelW(LPCWSTR lpRootPathName, LPCWSTR lpVolumeName)
    4747{
    48   char *asciiroot, *asciivolname;
    49   BOOL  rc;
     48    char *asciiroot, *asciivolname;
     49    BOOL  rc;
    5050
    5151    dprintf(("KERNEL32:  OS2SetVolumeLabelW\n"));
     
    6464                                PDWORD lpClusters)
    6565{
    66   BOOL rc;
    67   DWORD dwSectorsPerCluster;    // address of sectors per cluster ter
    68   DWORD dwBytesPerSector;   // address of bytes per sector
    69   DWORD dwNumberOfFreeClusters; // address of number of free clusters
    70   DWORD dwTotalNumberOfClusters;    // address of total number of clusters
    71 
    72   rc = OSLibGetDiskFreeSpace((LPSTR)lpszRootPathName, &dwSectorsPerCluster, &dwBytesPerSector,
    73                              &dwNumberOfFreeClusters, &dwTotalNumberOfClusters);
    74   if(rc)
    75   {
    76     if (lpSectorsPerCluster!=NULL)
    77       *lpSectorsPerCluster = dwSectorsPerCluster;
    78     if (lpBytesPerSector!=NULL)
    79       *lpBytesPerSector = dwBytesPerSector;
    80     if (lpFreeClusters!=NULL)
    81       *lpFreeClusters = dwNumberOfFreeClusters;
    82     if (lpClusters!=NULL)
    83       *lpClusters = dwTotalNumberOfClusters;
     66    BOOL rc;
     67    DWORD dwSectorsPerCluster;    // address of sectors per cluster ter
     68    DWORD dwBytesPerSector;   // address of bytes per sector
     69    DWORD dwNumberOfFreeClusters; // address of number of free clusters
     70    DWORD dwTotalNumberOfClusters;    // address of total number of clusters
     71
     72    rc = OSLibGetDiskFreeSpace((LPSTR)lpszRootPathName, &dwSectorsPerCluster, &dwBytesPerSector,
     73                                &dwNumberOfFreeClusters, &dwTotalNumberOfClusters);
     74    if(rc)
     75    {
     76        if (lpSectorsPerCluster!=NULL)
     77            *lpSectorsPerCluster = dwSectorsPerCluster;
     78        if (lpBytesPerSector!=NULL)
     79            *lpBytesPerSector = dwBytesPerSector;
     80        if (lpFreeClusters!=NULL)
     81            *lpFreeClusters = dwNumberOfFreeClusters;
     82        if (lpClusters!=NULL)
     83            *lpClusters = dwTotalNumberOfClusters;
    8484
    8585    /* CW: Windows Media Player setup complains about wrong clustersize when odin is installed on
     
    9090       TVFSTOHPFS = 1
    9191       */
    92     if(lpSectorsPerCluster!=NULL)
    93     {
    94       if(*lpSectorsPerCluster==1024 && PROFILE_GetOdinIniBool("DRIVESPACE","CLUSTERTO32",0))
    95       {/* TVFS returns 1024 sectors per cluster */
    96         dprintf(("KERNEL32:  GetDiskFreeSpaceA, TVFS-Drive detected. Faking clustersize to 32.\n"));
    97         *lpSectorsPerCluster=32;
    98         if (lpFreeClusters!=NULL)
    99           *lpFreeClusters = dwNumberOfFreeClusters<<0x5;
    100         if (lpClusters!=NULL)
    101           *lpClusters = dwTotalNumberOfClusters<<0x5;
    102       }
    103     }
    104   }
    105   return rc;
     92        if(lpSectorsPerCluster!=NULL)
     93        {
     94            if(*lpSectorsPerCluster==1024 && PROFILE_GetOdinIniBool("DRIVESPACE","CLUSTERTO32",0))
     95            {/* TVFS returns 1024 sectors per cluster */
     96                dprintf(("KERNEL32:  GetDiskFreeSpaceA, TVFS-Drive detected. Faking clustersize to 32.\n"));
     97                *lpSectorsPerCluster=32;
     98                if (lpFreeClusters!=NULL)
     99                    *lpFreeClusters = dwNumberOfFreeClusters<<0x5;
     100                if (lpClusters!=NULL)
     101                    *lpClusters = dwTotalNumberOfClusters<<0x5;
     102            }
     103        }
     104    }
     105    return rc;
    106106}
    107107//******************************************************************************
     
    113113                                PDWORD  lpClusters)
    114114{
    115   BOOL  rc;
    116   char *astring;
    117 
    118   astring = UnicodeToAsciiString((LPWSTR)lpszRootPathName);
    119   rc = GetDiskFreeSpaceA(astring, lpSectorsPerCluster, lpBytesPerSector, lpFreeClusters, lpClusters);
    120   FreeAsciiString(astring);
    121   return(rc);
     115    BOOL  rc;
     116    char *astring;
     117
     118    astring = UnicodeToAsciiString((LPWSTR)lpszRootPathName);
     119    rc = GetDiskFreeSpaceA(astring, lpSectorsPerCluster, lpBytesPerSector, lpFreeClusters, lpClusters);
     120    FreeAsciiString(astring);
     121    return(rc);
    122122}
    123123
     
    202202                                  PULARGE_INTEGER lpTotalNumberOfFreeBytes )
    203203{
    204  BOOL  rc;
    205  char *astring;
     204    BOOL  rc;
     205    char *astring;
    206206
    207207    dprintf(("KERNEL32:  OS2GetDiskFreeSpaceExW\n"));
     
    216216UINT WIN32API GetDriveTypeA(LPCSTR lpszDrive)
    217217{
    218    UINT rc;
    219    ULONG driveIndex;
     218    UINT rc;
     219    ULONG driveIndex;
    220220
    221221    if(lpszDrive == 0) {
     
    259259UINT WIN32API GetDriveTypeW(LPCWSTR lpszDrive)
    260260{
    261  UINT  rc;
    262  char *astring;
     261    UINT  rc;
     262    char *astring;
    263263
    264264    if(lpszDrive == (LPCWSTR)-1) {
     
    270270    FreeAsciiString(astring);
    271271    return(rc);
     272}
     273//******************************************************************************
     274static int fForce2GBFileSize = FALSE;
     275//******************************************************************************
     276void WIN32API CustForce2GBFileSize()
     277{
     278    fForce2GBFileSize = TRUE;
    272279}
    273280//******************************************************************************
     
    369376                strcpy(lpFileSystemNameBuffer, "FAT16");
    370377            }
     378            if(fForce2GBFileSize) {
     379                if(strcmp(lpFileSystemNameBuffer, "CDFS") &&
     380                   strcmp(lpFileSystemNameBuffer, "UDF"))
     381                {//everything is FAT -> 2 GB file size limit
     382                    strcpy(lpFileSystemNameBuffer, "FAT16");
     383                }
     384            }
    371385            dprintf2(("Final file system name: %s", lpFileSystemNameBuffer));
    372386        }
     
    414428                                    DWORD   nFileSystemNameSize)
    415429{
    416   char *asciiroot,
    417        *asciivol,
    418        *asciifs;
    419   BOOL  rc;
    420 
    421   // transform into ascii
    422   asciivol  = (char *)malloc(nVolumeNameSize+1);
    423   asciifs   = (char *)malloc(nFileSystemNameSize+1);
    424 
    425   // clear ascii buffers
    426   memset (asciivol, 0, (nVolumeNameSize + 1));
    427   memset (asciifs,  0, (nFileSystemNameSize + 1));
    428 
    429   if (lpRootPathName != NULL) // NULL is valid!
    430     asciiroot = UnicodeToAsciiString((LPWSTR)lpRootPathName);
    431   else
    432     asciiroot = NULL;
    433 
    434   rc = GetVolumeInformationA(asciiroot,
    435                              asciivol,
    436                              nVolumeNameSize,
    437                              lpVolumeSerialNumber,
    438                              lpMaximumComponentLength,
    439                              lpFileSystemFlags,
    440                              asciifs,
    441                              nFileSystemNameSize);
     430    char *asciiroot,
     431         *asciivol,
     432         *asciifs;
     433    BOOL  rc;
     434
     435    // transform into ascii
     436    asciivol  = (char *)malloc(nVolumeNameSize+1);
     437    asciifs   = (char *)malloc(nFileSystemNameSize+1);
     438
     439    // clear ascii buffers
     440    memset (asciivol, 0, (nVolumeNameSize + 1));
     441    memset (asciifs,  0, (nFileSystemNameSize + 1));
     442
     443    if (lpRootPathName != NULL) // NULL is valid!
     444        asciiroot = UnicodeToAsciiString((LPWSTR)lpRootPathName);
     445    else
     446        asciiroot = NULL;
     447
     448    rc = GetVolumeInformationA(asciiroot, asciivol, nVolumeNameSize, lpVolumeSerialNumber,
     449                               lpMaximumComponentLength, lpFileSystemFlags, asciifs, nFileSystemNameSize);
    442450
    443451    if (lpVolumeNameBuffer != NULL)  /* @@@PH 98/06/07 */
    444       AsciiToUnicodeN(asciivol, lpVolumeNameBuffer, nVolumeNameSize);
     452        AsciiToUnicodeN(asciivol, lpVolumeNameBuffer, nVolumeNameSize);
    445453
    446454    if (lpFileSystemNameBuffer != NULL)  /* @@@PH 98/06/07 */
    447       AsciiToUnicodeN(asciifs, lpFileSystemNameBuffer, nFileSystemNameSize);
    448 
    449 
    450   if (asciiroot != NULL)
    451     FreeAsciiString(asciiroot);
    452 
    453   free(asciifs);
    454   free(asciivol);
    455   return(rc);
     455        AsciiToUnicodeN(asciifs, lpFileSystemNameBuffer, nFileSystemNameSize);
     456
     457    if (asciiroot != NULL)
     458        FreeAsciiString(asciiroot);
     459
     460    free(asciifs);
     461    free(asciivol);
     462    return(rc);
    456463}
    457464//******************************************************************************
     
    473480UINT WIN32API GetLogicalDriveStringsW(UINT nBufferLength, LPWSTR lpBuffer)
    474481{
    475   char *asciibuffer = (char *)malloc(nBufferLength+1);
    476   DWORD rc;
     482    char *asciibuffer = (char *)malloc(nBufferLength+1);
     483    DWORD rc;
    477484
    478485    dprintf(("KERNEL32:  OS2GetLogicalDriveStringsW\n"));
     
    562569    DWORD    DeviceType;
    563570    char     szVolume[256];
     571
     572    //tetsetsetetsetsetset
     573    SetLastError(ERROR_NO_MORE_FILES);
     574    return FALSE;
     575    //tetsetsetetsetsetset
    564576
    565577    if(!VERSION_IS_WIN2000_OR_HIGHER()) {
Note: See TracChangeset for help on using the changeset viewer.