home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / FILES202.ZIP / UTILITY.C < prev   
C/C++ Source or Header  |  1989-02-23  |  1KB  |  68 lines

  1. /* utility.c
  2. **
  3. ** Copyright (c) 1988-89, Christopher Laforet
  4. ** All Rights Reserved
  5. **
  6. ** (v1.xx) for Turbo-C
  7. ** (v2.xx) for OS/2 - CML 2-89
  8. **
  9. */
  10.  
  11. #define LINT_ARGS
  12.  
  13.  
  14. #include <stdio.h>
  15. #include <ctype.h>
  16. #include <os2.h>
  17. #include "files.h"
  18.  
  19.  
  20. unsigned char *months[] =
  21.     {
  22.     "Jan",
  23.     "Feb",
  24.     "Mar",
  25.     "Apr",
  26.     "May",
  27.     "Jun",
  28.     "Jul",
  29.     "Aug",
  30.     "Sep",
  31.     "Oct",
  32.     "Nov",
  33.     "Dec",
  34.     };
  35.  
  36.  
  37. void convert_date(date,date_string)
  38. FDATE *date;
  39. unsigned char *date_string;
  40.     {
  41.     sprintf(date_string,"%2u-%3.3s-%4.4u",date->day,months[date->month - 1],1980 + date->year);
  42.     }
  43.  
  44.  
  45. void convert_time(time,time_string)
  46. FTIME *time;
  47. unsigned char *time_string;
  48.     {
  49.     sprintf(time_string,"%2u:%02u",time->hours,time->minutes);
  50.     }
  51.  
  52.  
  53. unsigned long get_disk_space(path)
  54. unsigned char *path;
  55.     {
  56.     FSALLOCATE diskinfo;
  57.     unsigned short drive = 0;        /* default drive */
  58.     unsigned long rtn;
  59.  
  60.     if (path[1] == ':')     /* drive specifier? */
  61.         {
  62.         drive = (toupper(path[0]) - 'A') + 1;
  63.         }
  64.     DosQFSInfo(drive,1,(PBYTE)&diskinfo,sizeof(FSALLOCATE));
  65.     rtn = diskinfo.cUnitAvail * diskinfo.cSectorUnit * diskinfo.cbSector;
  66.     return(rtn);
  67.     }
  68.