Changeset 897 for trunk/dll/valid.c


Ignore:
Timestamp:
Dec 31, 2007, 12:34:00 AM (18 years ago)
Author:
Gregg Young
Message:

Use CommaFmtULL for additional file, EA etc sizes display; Modify/Create TestFDates & TestCDates for comparing/sorting files or CNRITEMS by date/time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/valid.c

    r850 r897  
    2424  16 Jun 07 SHL Update for OpenWatcom
    2525  20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
     26  30 Dec 07 GKY Change TestDates to TestFDates can compare by filename or FDATE/FTIME data
     27  30 Dec 07 GKY Add TestCDates to compare CNRITEMs by CDATE/CTIME data
    2628
    2729***********************************************************************/
     
    7880}
    7981
    80 int TestDates(char *file1, char *file2)
     82int TestFDates(char *file1, char *file2, FDATE *datevar1, FTIME *timevar1,
     83               FDATE *datevar2, FTIME *timevar2)
     84{
     85  /*
     86   * return 1 (file2 newer than file1),
     87   * 0 (files same)
     88   * or -1 (file1 newer than file2)
     89   * Make the FILSTATUS pointers NULL if passing file names
     90   * if the FILESTATUS information is already available it can be passed instead
     91   * Make the files NULL if passing FILESTATUS buffers
     92   */
     93
     94  int comp = 0;
     95  FILESTATUS3 fs3o, fs3n;
     96
     97  if (file1){
     98    DosError(FERR_DISABLEHARDERR);
     99    DosQueryPathInfo(file1, FIL_STANDARD, &fs3o, sizeof(fs3o));
     100    datevar1 = &fs3o.fdateLastWrite;
     101    timevar1 = &fs3o.ftimeLastWrite;
     102  }
     103  if (file2) {
     104    DosError(FERR_DISABLEHARDERR);
     105    DosQueryPathInfo(file2, FIL_STANDARD, &fs3n, sizeof(fs3n));
     106    datevar2 = &fs3n.fdateLastWrite;
     107    timevar2 = &fs3n.ftimeLastWrite;
     108  }
     109  if (&datevar1 && &datevar2 && &timevar1 && &timevar2) {
     110    comp = (datevar2->year >
     111            datevar1->year) ? 1 :
     112      (datevar2->year <
     113       datevar1->year) ? -1 :
     114      (datevar2->month >
     115       datevar1->month) ? 1 :
     116      (datevar2->month <
     117       datevar1->month) ? -1 :
     118      (datevar2->day >
     119       datevar1->day) ? 1 :
     120      (datevar2->day <
     121       datevar1->day) ? -1 :
     122      (timevar2->hours >
     123       timevar1->hours) ? 1 :
     124      (timevar2->hours <
     125       timevar1->hours) ? -1 :
     126      (timevar2->minutes >
     127       timevar1->minutes) ? 1 :
     128      (timevar2->minutes <
     129       timevar1->minutes) ? -1 :
     130      (timevar2->twosecs >
     131       timevar1->twosecs) ? 1 :
     132    (timevar2->twosecs < timevar1->twosecs) ? -1 : 0;
     133  }
     134    return comp;
     135}
     136
     137int TestCDates(CDATE *datevar1, CTIME *timevar1,
     138               CDATE *datevar2, CTIME *timevar2)
    81139{
    82140  /*
     
    87145
    88146  int comp = 0;
    89   FILESTATUS3 fs3o, fs3n;
    90 
    91   DosError(FERR_DISABLEHARDERR);
    92   if (!DosQueryPathInfo(file1, FIL_STANDARD, &fs3o, sizeof(fs3o))) {
    93     DosError(FERR_DISABLEHARDERR);
    94     if (!DosQueryPathInfo(file2, FIL_STANDARD, &fs3n, sizeof(fs3n))) {
    95       comp = (fs3n.fdateLastWrite.year >
    96               fs3o.fdateLastWrite.year) ? 1 :
    97         (fs3n.fdateLastWrite.year <
    98          fs3o.fdateLastWrite.year) ? -1 :
    99         (fs3n.fdateLastWrite.month >
    100          fs3o.fdateLastWrite.month) ? 1 :
    101         (fs3n.fdateLastWrite.month <
    102          fs3o.fdateLastWrite.month) ? -1 :
    103         (fs3n.fdateLastWrite.day >
    104          fs3o.fdateLastWrite.day) ? 1 :
    105         (fs3n.fdateLastWrite.day <
    106          fs3o.fdateLastWrite.day) ? -1 :
    107         (fs3n.ftimeLastWrite.hours >
    108          fs3o.ftimeLastWrite.hours) ? 1 :
    109         (fs3n.ftimeLastWrite.hours <
    110          fs3o.ftimeLastWrite.hours) ? -1 :
    111         (fs3n.ftimeLastWrite.minutes >
    112          fs3o.ftimeLastWrite.minutes) ? 1 :
    113         (fs3n.ftimeLastWrite.minutes <
    114          fs3o.ftimeLastWrite.minutes) ? -1 :
    115         (fs3n.ftimeLastWrite.twosecs >
    116          fs3o.ftimeLastWrite.twosecs) ? 1 :
    117         (fs3n.ftimeLastWrite.twosecs < fs3o.ftimeLastWrite.twosecs) ? -1 : 0;
    118     }
    119   }
    120   return comp;
     147
     148  if (&datevar1 && &datevar2 && &timevar1 && &timevar2) {
     149    comp = (datevar2->year >
     150            datevar1->year) ? 1 :
     151      (datevar2->year <
     152       datevar1->year) ? -1 :
     153      (datevar2->month >
     154       datevar1->month) ? 1 :
     155      (datevar2->month <
     156       datevar1->month) ? -1 :
     157      (datevar2->day >
     158       datevar1->day) ? 1 :
     159      (datevar2->day <
     160       datevar1->day) ? -1 :
     161      (timevar2->hours >
     162       timevar1->hours) ? 1 :
     163      (timevar2->hours <
     164       timevar1->hours) ? -1 :
     165      (timevar2->minutes >
     166       timevar1->minutes) ? 1 :
     167      (timevar2->minutes <
     168       timevar1->minutes) ? -1 :
     169      (timevar2->seconds >
     170       timevar1->seconds) ? 1 :
     171    (timevar2->seconds < timevar1->seconds) ? -1 : 0;
     172  }
     173    return comp;
    121174}
    122175
     
    125178  /* return TRUE if file2 is newer than file1 */
    126179
    127   return (TestDates(file1, file2) > 0);
     180  return (TestFDates(file1, file2, NULL, NULL, NULL, NULL) > 0);
    128181}
    129182
     
    941994#pragma alloc_text(VALID,CheckDrive,IsRoot,IsFile,IsFullName,needsquoting)
    942995#pragma alloc_text(VALID,IsValidDir,IsValidDrive,MakeValidDir,IsVowel)
    943 #pragma alloc_text(VALID,IsFileSame,IsNewer,TestDates,RootName,MakeFullName)
     996#pragma alloc_text(VALID,IsFileSame,IsNewer,TestFDates,TestCDates,RootName,MakeFullName)
    944997#pragma alloc_text(VALID,IsExecutable,IsBinary,IsDesktop,ParentIsDesktop)
    945998#pragma alloc_text(FILLFLAGS,FillInDriveFlags,assign_ignores)
Note: See TracChangeset for help on using the changeset viewer.