Ignore:
Timestamp:
Dec 11, 2000, 8:54:20 AM (25 years ago)
Author:
umoeller
Message:

Coupla bugfixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/dosh.c

    r14 r15  
    178178
    179179    return (s_brc);
    180 }
    181 
    182 /*
    183  *@@ doshQueryAvailPhysMem:
    184  *      returns the amount of physical memory which
    185  *      is presently available (before the swapper
    186  *      would have to be expanded).
    187  *
    188  *      This number is calculated by getting the
    189  *      total available memory (QSV_TOTRESMEM)
    190  *      and subtracting the free space on the
    191  *      drive with the swap file from it.
    192  *
    193  *      As a result, you also need to specify
    194  *      the logical drive on which the swapper
    195  *      resides (3 = C, 4 = D, and so on).
    196  *
    197  *@@added V0.9.7 (2000-12-01) [umoeller]
    198  */
    199 
    200 APIRET doshQueryAvailPhysMem(PULONG pulMem,
    201                              ULONG ulLogicalSwapDrive)
    202 {
    203     APIRET arc = DosQuerySysInfo(QSV_TOTAVAILMEM,
    204                                  QSV_TOTAVAILMEM,
    205                                  pulMem,
    206                                  sizeof(*pulMem));
    207     if (arc == NO_ERROR)
    208     {
    209         double dFree = 0;
    210         arc = doshQueryDiskFree(ulLogicalSwapDrive,
    211                                 &dFree);
    212         *pulMem -= (ULONG)dFree;
    213     }
    214 
    215     return (arc);
    216180}
    217181
     
    895859 *
    896860 *@@added V0.9.6 (2000-10-16) [umoeller]
     861 *@@changed V0.9.7 (2000-12-10) [umoeller]: fixed "F:filename.ext" case
    897862 */
    898863
    899864PSZ doshGetExtension(const char *pcszFilename)
    900865{
    901     PSZ pszExtension = 0;
     866    PSZ pReturn = NULL;
    902867
    903868    if (pcszFilename)
    904869    {
    905870        // find filename
    906         PSZ p2 = strrchr(pcszFilename + 2, '\\'),
    907                     // works on "C:\blah" or "\\unc\blah"
    908             p3 = NULL;
    909 
    910         if (!p2)
    911             // no backslash found: then this is not qualified...
    912             // use start of filename
    913             p2 = (PSZ)pcszFilename;
     871        const char *p2 = strrchr(pcszFilename + 2, '\\'),
     872                            // works on "C:\blah" or "\\unc\blah"
     873                   *pStartOfName = NULL,
     874                   *pExtension = NULL;
     875
     876        if (p2)
     877            pStartOfName = p2 + 1;
     878        else
     879        {
     880            // no backslash found:
     881            // maybe only a drive letter was specified:
     882            if (*(pcszFilename + 1) == ':')
     883                // yes:
     884                pStartOfName = pcszFilename + 2;
     885            else
     886                // then this is not qualified at all...
     887                // use start of filename
     888                pStartOfName = (PSZ)pcszFilename;
     889        }
    914890
    915891        // find last dot in filename
    916         p3 = strrchr(p2 + 1, '.');
    917         if (p3)
    918             pszExtension = p3 + 1;
    919     }
    920 
    921     return (pszExtension);
     892        pExtension = strrchr(pStartOfName, '.');
     893        if (pExtension)
     894            pReturn = (PSZ)pExtension + 1;
     895    }
     896
     897    return (pReturn);
    922898}
    923899
Note: See TracChangeset for help on using the changeset viewer.