Changeset 551 for trunk/dll/rename.c


Ignore:
Timestamp:
Feb 28, 2007, 2:33:51 AM (19 years ago)
Author:
Gregg Young
Message:

Indentation cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/rename.c

    r123 r551  
    2626#pragma alloc_text(FMRENAME,RenameProc)
    2727
    28 
    29 MRESULT EXPENTRY RenameProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
     28MRESULT EXPENTRY RenameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     29{
    3030
    3131  MOVEIT *mv;
    3232
    33   switch(msg) {
    34     case WM_INITDLG:
    35       mv = (MOVEIT *)mp2;
    36       WinSetWindowPtr(hwnd,0,(PVOID)mv);
    37       if(!mv || !mv->source) {
    38         WinDismissDlg(hwnd,0);
    39         break;
    40       }
    41       WinSendDlgItemMsg(hwnd,
    42                         REN_SOURCE,
    43                         EM_SETTEXTLIMIT,
    44                         MPFROM2SHORT(CCHMAXPATH,0),
    45                         MPVOID);
    46       WinSendDlgItemMsg(hwnd,
    47                         REN_TARGET,
    48                         EM_SETTEXTLIMIT,
    49                         MPFROM2SHORT(CCHMAXPATH,0),
    50                         MPVOID);
    51       if(!*mv->target)
    52         strcpy(mv->target,mv->source);
    53       WinSendMsg(hwnd,
    54                  UM_RESCAN,
    55                  MPVOID,
    56                  MPVOID);
    57       if(mv->rename ||
    58          !stricmp(mv->target,mv->source)) {
    59 
    60         CHAR *p;
    61 
    62         p = strrchr(mv->target,'\\');
    63         if(p) {
    64 
    65           USHORT sello,selhi;
    66 
    67           sello = (p - mv->target) + 1;
    68           selhi = strlen(mv->target);
    69 
    70           WinSendDlgItemMsg(hwnd,
    71                             REN_TARGET,
    72                             EM_SETSEL,
    73                             MPFROM2SHORT(sello,selhi),
    74                             MPVOID);
    75         }
     33  switch (msg) {
     34  case WM_INITDLG:
     35    mv = (MOVEIT *) mp2;
     36    WinSetWindowPtr(hwnd, 0, (PVOID) mv);
     37    if (!mv || !mv->source) {
     38      WinDismissDlg(hwnd, 0);
     39      break;
     40    }
     41    WinSendDlgItemMsg(hwnd,
     42                      REN_SOURCE,
     43                      EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     44    WinSendDlgItemMsg(hwnd,
     45                      REN_TARGET,
     46                      EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     47    if (!*mv->target)
     48      strcpy(mv->target, mv->source);
     49    WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     50    if (mv->rename || !stricmp(mv->target, mv->source)) {
     51
     52      CHAR *p;
     53
     54      p = strrchr(mv->target, '\\');
     55      if (p) {
     56
     57        USHORT sello, selhi;
     58
     59        sello = (p - mv->target) + 1;
     60        selhi = strlen(mv->target);
     61
     62        WinSendDlgItemMsg(hwnd,
     63                          REN_TARGET,
     64                          EM_SETSEL, MPFROM2SHORT(sello, selhi), MPVOID);
     65      }
    7666//        WinShowWindow(WinWindowFromID(hwnd,REN_DONTASK),FALSE);
    77         WinShowWindow(WinWindowFromID(hwnd,REN_OVEROLD),FALSE);
    78         WinShowWindow(WinWindowFromID(hwnd,REN_OVERNEW),FALSE);
    79       }
    80       break;
    81 
    82     case UM_RESCAN:
    83       {
    84         mv = WinQueryWindowPtr(hwnd,0);
    85         if(mv) {
    86 
    87           FILESTATUS3 fs1,fs2;
    88           CHAR        s[CCHMAXPATH * 2],*p,chkname[CCHMAXPATH];
    89           INT         sourceexists = 0,targetexists = 0,
    90                       sourcenewer = 0,sourcesmaller = 0;
    91 
    92           p = mv->target;
    93           while(*p) {
    94             if(*p == '/')
    95               *p = '\\';
    96             p++;
    97           }
    98           if(!MakeFullName(mv->target))
    99             WinSetDlgItemText(hwnd,
    100                               REN_TARGET,
    101                               mv->target);
    102           if(!MakeFullName(mv->source))
    103             WinSetDlgItemText(hwnd,
    104                               REN_SOURCE,
    105                               mv->source);
    106           if(!DosQueryPathInfo(mv->source,
    107                                FIL_STANDARD,
    108                                &fs1,
    109                                sizeof(fs1))) {
    110             sprintf(s,
    111                     " %s%lu %ss %04u/%02u/%02u %02u:%02u:%02u",
    112                     (fs1.attrFile & FILE_DIRECTORY) ?
    113                      GetPString(IDS_DIRBRKTTEXT) :
    114                      NullStr,
    115                     fs1.cbFile,
    116                     GetPString(IDS_BYTETEXT),
    117                     fs1.fdateLastWrite.year + 1980,
    118                     fs1.fdateLastWrite.month,
    119                     fs1.fdateLastWrite.day,
    120                     fs1.ftimeLastWrite.hours,
    121                     fs1.ftimeLastWrite.minutes,
    122                     fs1.ftimeLastWrite.twosecs * 2);
    123             WinSetDlgItemText(hwnd,REN_SOURCEINFO,s);
    124             sourceexists = 1;
    125             if(fs1.attrFile & (FILE_DIRECTORY))
    126               sourceexists = 3;
    127           }
    128           else
    129             WinSetDlgItemText(hwnd,
    130                               REN_SOURCEINFO,
    131                               GetPString(IDS_DOESNTEXIST2TEXT));
    132           strcpy(chkname,mv->target);
    133           p = strrchr(s,'\\');
    134           if(p &&
    135              (strchr(p,'*') ||
    136               strchr(p,'?'))) {
    137             if(!AdjustWildcardName(mv->target,chkname))
    138               strcpy(chkname,mv->target);
    139           }
    140           if(!DosQueryPathInfo(chkname,
    141                                FIL_STANDARD,
    142                                &fs2,
    143                                sizeof(fs2))) {
    144             sprintf(s,
    145                     " %s%lu %ss %04u/%02u/%02u %02u:%02u:%02u",
    146                     (fs2.attrFile & FILE_DIRECTORY) ?
    147                      GetPString(IDS_DIRBRKTTEXT) :
    148                      NullStr,
    149                     fs2.cbFile,
    150                     GetPString(IDS_BYTETEXT),
    151                     fs2.fdateLastWrite.year + 1980,
    152                     fs2.fdateLastWrite.month,
    153                     fs2.fdateLastWrite.day,
    154                     fs2.ftimeLastWrite.hours,
    155                     fs2.ftimeLastWrite.minutes,
    156                     fs2.ftimeLastWrite.twosecs * 2);
    157             WinSetDlgItemText(hwnd,REN_TARGETINFO,s);
    158             targetexists = 1;
    159             if(fs2.attrFile & (FILE_DIRECTORY))
    160               targetexists = 3;
    161             WinEnableWindow(WinWindowFromID(hwnd,REN_RENEXIST),
    162                             TRUE);
    163           }
    164           else {
    165             WinSetDlgItemText(hwnd,
    166                               REN_TARGETINFO,
    167                               GetPString(IDS_DOESNTEXIST2TEXT));
    168             WinEnableWindow(WinWindowFromID(hwnd,REN_RENEXIST),
    169                             FALSE);
    170           }
    171           *s = 0;
    172           if(sourceexists)
    173             sprintf(s,
    174                     GetPString(IDS_SOURCEISATEXT),
    175                     (sourceexists & 2) ?
    176                      GetPString(IDS_DIRECTORYTEXT) :
    177                      GetPString(IDS_FILETEXT));
    178           {
    179             FILE *fp = NULL;
    180 
    181             if(!(sourceexists & 2))
    182               fp = fopen(mv->source,"ab");
    183             if((!fp && !(sourceexists & 2)) || !sourceexists)
    184               strcpy(s,
    185                      GetPString(IDS_CANTACCESSSOURCETEXT));
    186             if(fp)
    187               fclose(fp);
    188           }
    189           if(targetexists &&
    190              stricmp(mv->source,mv->target))
    191             sprintf(&s[strlen(s)],
    192                     GetPString(IDS_TARGETEXISTSISATEXT),
    193                     (targetexists & 2) ?
    194                      GetPString(IDS_DIRECTORYTEXT) :
    195                      GetPString(IDS_FILETEXT));
    196           if(targetexists &&
    197              stricmp(mv->source,mv->target))
    198             strcpy(&s[strlen(s)],
    199                    GetPString(IDS_CLICKOVERWRITETEXT));
    200           else if(targetexists &&
    201                   !stricmp(mv->source,mv->target))
    202             strcpy(&s[strlen(s)],
    203                    GetPString(IDS_ENTERNEWTARGETTEXT));
    204           WinEnableWindow(WinWindowFromID(hwnd,REN_OVERWRITE),
    205                           (stricmp(mv->target,mv->source) &&
    206                            (!mv->rename ||
    207                             strcmp(mv->target,mv->source))));
    208 
    209           if(targetexists == 1 && sourceexists == 1) {
    210             sourcenewer = (fs1.fdateLastWrite.year < fs2.fdateLastWrite.year) ? 1 :
    211                            (fs1.fdateLastWrite.year > fs2.fdateLastWrite.year) ? -1 :
    212                            (fs1.fdateLastWrite.month < fs2.fdateLastWrite.month) ? 1 :
    213                            (fs1.fdateLastWrite.month > fs2.fdateLastWrite.month) ? -1 :
    214                            (fs1.fdateLastWrite.day < fs2.fdateLastWrite.day) ? 1 :
    215                            (fs1.fdateLastWrite.day > fs2.fdateLastWrite.day) ? -1 :
    216                            (fs1.ftimeLastWrite.hours < fs2.ftimeLastWrite.hours) ? 1 :
    217                            (fs1.ftimeLastWrite.hours > fs2.ftimeLastWrite.hours) ? -1 :
    218                            (fs1.ftimeLastWrite.minutes < fs2.ftimeLastWrite.minutes) ? 1 :
    219                            (fs1.ftimeLastWrite.minutes > fs2.ftimeLastWrite.minutes) ? -1 :
    220                            (fs1.ftimeLastWrite.twosecs < fs2.ftimeLastWrite.twosecs) ? 1 :
    221                            (fs1.ftimeLastWrite.twosecs > fs2.ftimeLastWrite.twosecs) ? -1 : 0;
    222             sourcesmaller = (fs1.cbFile < fs2.cbFile) ? -1 :
    223                             (fs1.cbFile > fs2.cbFile) ? 1 : 0;
    224             sprintf(&s[strlen(s)],
    225                     GetPString(IDS_SOURCEISTEXT),
    226                     (sourcenewer == -1) ? GetPString(IDS_NEWERTEXT) :
    227                      (sourcenewer == 1) ? GetPString(IDS_OLDERTEXT) :
    228                       GetPString(IDS_SAMEDATETEXT),
    229                     (sourcesmaller == -1) ? GetPString(IDS_SMALLERTEXT) :
    230                      (sourcesmaller == 1) ? GetPString(IDS_LARGERTEXT) :
    231                       GetPString(IDS_SAMESIZETEXT));
    232           }
    233           WinSetDlgItemText(hwnd,
    234                             REN_INFORMATION,
    235                             s);
    236           if(targetexists &&
    237              stricmp(mv->source,mv->target)) {
    238             if(WinQueryButtonCheckstate(hwnd,REN_DONTASK))
    239               return 0;
    240             return MRFROM2SHORT(1,0);
    241           }
    242           else if(targetexists &&
    243                   !stricmp(mv->source,mv->target)) {
    244             if(mv->rename &&
    245                strcmp(mv->source,mv->target))
    246               return 0;
    247             WinEnableWindow(WinWindowFromID(hwnd,REN_RENEXIST),
    248                             FALSE);
    249             return MRFROM2SHORT(2,0);
    250           }
    251         }
    252       }
    253       return 0;
    254 
    255     case WM_COMMAND:
    256       switch(SHORT1FROMMP(mp1)) {
    257         case DID_CANCEL:
    258           WinDismissDlg(hwnd,0);
    259           break;
    260 
    261         case IDM_HELP:
    262           if(hwndHelp)
    263             WinSendMsg(hwndHelp,
    264                        HM_DISPLAY_HELP,
    265                        MPFROM2SHORT(HELP_RENAME,0),
    266                        MPFROMSHORT(HM_RESOURCEID));
    267           break;
    268 
    269         case REN_SKIP:
    270           mv = WinQueryWindowPtr(hwnd,0);
    271           if(mv) {
    272             mv->skip = TRUE;
    273             *mv->target = 0;
    274             WinDismissDlg(hwnd,2);
    275           }
    276           else
    277             WinDismissDlg(hwnd,0);
    278           break;
    279 
    280         case REN_RENEXIST:
    281           mv = WinQueryWindowPtr(hwnd,0);
    282           if(mv) {
    283 
    284             CHAR   newexist[CCHMAXPATH],fullname[CCHMAXPATH];
    285             INT    was;
    286             APIRET rc;
    287 
    288             *newexist = 0;
    289             WinQueryDlgItemText(hwnd,
    290                                 REN_TARGET,
    291                                 CCHMAXPATH,
    292                                 newexist);
    293             if(*newexist) {
    294               if(DosQueryPathInfo(newexist,
    295                                   FIL_QUERYFULLNAME,
    296                                   fullname,
    297                                   sizeof(fullname)))
    298                 strcpy(fullname,newexist);
    299               was = IsFile(fullname);
    300               if(was == -1) {
    301                 rc = docopyf(MOVE,
    302                              mv->target,
    303                              "%s",
    304                              fullname);
    305                 if(rc) {
    306                   if((LONG)rc > 0)
    307                     Dos_Error(MB_CANCEL,
    308                               rc,
    309                               hwnd,
    310                               __FILE__,
    311                               __LINE__,
    312                               GetPString(IDS_COMPMOVEFAILEDTEXT),
    313                               mv->target,
    314                               fullname);
    315                   else
    316                     saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
    317                            hwnd,
    318                            GetPString(IDS_SORRYTEXT),
    319                            GetPString(IDS_COMPMOVEFAILEDTEXT),
    320                            mv->target,
    321                            fullname);
    322                 }
    323                 else
    324                   saymsg(MB_ENTER,
    325                          hwnd,
    326                          GetPString(IDS_SUCCESSTEXT),
    327                          GetPString(IDS_WASMOVEDTOTEXT),
    328                          mv->target,
    329                          fullname);
    330               }
    331               else
    332                 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
    333                        hwnd,
    334                        GetPString(IDS_SORRYTEXT),
    335                        GetPString(IDS_EXISTSASATEXT),
    336                        fullname,
    337                        (was) ?
    338                         GetPString(IDS_FILETEXT) :
    339                         GetPString(IDS_DIRECTORYTEXT));
    340             }
    341             WinSetDlgItemText(hwnd,
    342                               REN_TARGET,
    343                               mv->target);
    344           }
    345           break;
    346 
    347         case REN_OVERWRITE:
    348         case DID_OK:
    349           mv = WinQueryWindowPtr(hwnd,0);
    350           if(mv) {
    351 
    352             MRESULT mr;
    353 
    354             if(WinQueryButtonCheckstate(hwnd,REN_DONTASK))
    355               mv->dontask = TRUE;
    356             if(WinQueryButtonCheckstate(hwnd,REN_OVEROLD))
    357               mv->overold = TRUE;
    358             if(WinQueryButtonCheckstate(hwnd,REN_OVERNEW))
    359               mv->overnew = TRUE;
    360             *mv->target = 0;
    361             WinQueryDlgItemText(hwnd,
    362                                 REN_TARGET,
    363                                 CCHMAXPATH,
    364                                 mv->target);
    365             bstrip(mv->target);
    366             mr = WinSendMsg(hwnd,
    367                             UM_RESCAN,
    368                             MPVOID,
    369                             MPVOID);
    370             if(!mr ||
    371                (SHORT1FROMMR(mr) != 2 &&
    372                 SHORT1FROMMP(mp1) == REN_OVERWRITE)) {
    373 
    374               CHAR path[CCHMAXPATH],*p;
    375 
    376               mv->overwrite = (SHORT1FROMMP(mp1) == REN_OVERWRITE);
    377               strcpy(path,mv->target);
    378               p = strrchr(path,'\\');
    379               if(p) {
    380                 p++;
    381                 *p = 0;
    382                 if(SetDir(WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),
    383                                          QW_OWNER),
    384                           hwnd,
    385                           path,
    386                           0)) {
    387                   DosBeep(250,100);
    388                   WinSetFocus(HWND_DESKTOP,
    389                               WinWindowFromID(hwnd,REN_TARGET));
    390                   break;
    391                 }
    392               }
    393               WinDismissDlg(hwnd,1);
    394             }
    395             else {
    396               DosBeep(250,100);
    397               WinSetFocus(HWND_DESKTOP,
    398                           WinWindowFromID(hwnd,REN_TARGET));
    399             }
    400           }
    401           break;
    402       }
    403       return 0;
     67      WinShowWindow(WinWindowFromID(hwnd, REN_OVEROLD), FALSE);
     68      WinShowWindow(WinWindowFromID(hwnd, REN_OVERNEW), FALSE);
     69    }
     70    break;
     71
     72  case UM_RESCAN:
     73    {
     74      mv = WinQueryWindowPtr(hwnd, 0);
     75      if (mv) {
     76
     77        FILESTATUS3 fs1, fs2;
     78        CHAR s[CCHMAXPATH * 2], *p, chkname[CCHMAXPATH];
     79        INT sourceexists = 0, targetexists = 0,
     80          sourcenewer = 0, sourcesmaller = 0;
     81
     82        p = mv->target;
     83        while (*p) {
     84          if (*p == '/')
     85            *p = '\\';
     86          p++;
     87        }
     88        if (!MakeFullName(mv->target))
     89          WinSetDlgItemText(hwnd, REN_TARGET, mv->target);
     90        if (!MakeFullName(mv->source))
     91          WinSetDlgItemText(hwnd, REN_SOURCE, mv->source);
     92        if (!DosQueryPathInfo(mv->source, FIL_STANDARD, &fs1, sizeof(fs1))) {
     93          sprintf(s,
     94                  " %s%lu %ss %04u/%02u/%02u %02u:%02u:%02u",
     95                  (fs1.attrFile & FILE_DIRECTORY) ?
     96                  GetPString(IDS_DIRBRKTTEXT) :
     97                  NullStr,
     98                  fs1.cbFile,
     99                  GetPString(IDS_BYTETEXT),
     100                  fs1.fdateLastWrite.year + 1980,
     101                  fs1.fdateLastWrite.month,
     102                  fs1.fdateLastWrite.day,
     103                  fs1.ftimeLastWrite.hours,
     104                  fs1.ftimeLastWrite.minutes, fs1.ftimeLastWrite.twosecs * 2);
     105          WinSetDlgItemText(hwnd, REN_SOURCEINFO, s);
     106          sourceexists = 1;
     107          if (fs1.attrFile & (FILE_DIRECTORY))
     108            sourceexists = 3;
     109        }
     110        else
     111          WinSetDlgItemText(hwnd,
     112                            REN_SOURCEINFO, GetPString(IDS_DOESNTEXIST2TEXT));
     113        strcpy(chkname, mv->target);
     114        p = strrchr(s, '\\');
     115        if (p && (strchr(p, '*') || strchr(p, '?'))) {
     116          if (!AdjustWildcardName(mv->target, chkname))
     117            strcpy(chkname, mv->target);
     118        }
     119        if (!DosQueryPathInfo(chkname, FIL_STANDARD, &fs2, sizeof(fs2))) {
     120          sprintf(s,
     121                  " %s%lu %ss %04u/%02u/%02u %02u:%02u:%02u",
     122                  (fs2.attrFile & FILE_DIRECTORY) ?
     123                  GetPString(IDS_DIRBRKTTEXT) :
     124                  NullStr,
     125                  fs2.cbFile,
     126                  GetPString(IDS_BYTETEXT),
     127                  fs2.fdateLastWrite.year + 1980,
     128                  fs2.fdateLastWrite.month,
     129                  fs2.fdateLastWrite.day,
     130                  fs2.ftimeLastWrite.hours,
     131                  fs2.ftimeLastWrite.minutes, fs2.ftimeLastWrite.twosecs * 2);
     132          WinSetDlgItemText(hwnd, REN_TARGETINFO, s);
     133          targetexists = 1;
     134          if (fs2.attrFile & (FILE_DIRECTORY))
     135            targetexists = 3;
     136          WinEnableWindow(WinWindowFromID(hwnd, REN_RENEXIST), TRUE);
     137        }
     138        else {
     139          WinSetDlgItemText(hwnd,
     140                            REN_TARGETINFO, GetPString(IDS_DOESNTEXIST2TEXT));
     141          WinEnableWindow(WinWindowFromID(hwnd, REN_RENEXIST), FALSE);
     142        }
     143        *s = 0;
     144        if (sourceexists)
     145          sprintf(s,
     146                  GetPString(IDS_SOURCEISATEXT),
     147                  (sourceexists & 2) ?
     148                  GetPString(IDS_DIRECTORYTEXT) : GetPString(IDS_FILETEXT));
     149        {
     150          FILE *fp = NULL;
     151
     152          if (!(sourceexists & 2))
     153            fp = fopen(mv->source, "ab");
     154          if ((!fp && !(sourceexists & 2)) || !sourceexists)
     155            strcpy(s, GetPString(IDS_CANTACCESSSOURCETEXT));
     156          if (fp)
     157            fclose(fp);
     158        }
     159        if (targetexists && stricmp(mv->source, mv->target))
     160          sprintf(&s[strlen(s)],
     161                  GetPString(IDS_TARGETEXISTSISATEXT),
     162                  (targetexists & 2) ?
     163                  GetPString(IDS_DIRECTORYTEXT) : GetPString(IDS_FILETEXT));
     164        if (targetexists && stricmp(mv->source, mv->target))
     165          strcpy(&s[strlen(s)], GetPString(IDS_CLICKOVERWRITETEXT));
     166        else if (targetexists && !stricmp(mv->source, mv->target))
     167          strcpy(&s[strlen(s)], GetPString(IDS_ENTERNEWTARGETTEXT));
     168        WinEnableWindow(WinWindowFromID(hwnd, REN_OVERWRITE),
     169                        (stricmp(mv->target, mv->source) &&
     170                         (!mv->rename || strcmp(mv->target, mv->source))));
     171
     172        if (targetexists == 1 && sourceexists == 1) {
     173          sourcenewer =
     174            (fs1.fdateLastWrite.year <
     175             fs2.fdateLastWrite.year) ? 1 : (fs1.fdateLastWrite.year >
     176                                             fs2.fdateLastWrite.
     177                                             year) ? -1 : (fs1.fdateLastWrite.
     178                                                           month <
     179                                                           fs2.fdateLastWrite.
     180                                                           month) ? 1 : (fs1.
     181                                                                         fdateLastWrite.
     182                                                                         month
     183                                                                         >
     184                                                                         fs2.
     185                                                                         fdateLastWrite.
     186                                                                         month)
     187            ? -1 : (fs1.fdateLastWrite.day <
     188                    fs2.fdateLastWrite.day) ? 1 : (fs1.fdateLastWrite.day >
     189                                                   fs2.fdateLastWrite.
     190                                                   day) ? -1 : (fs1.
     191                                                                ftimeLastWrite.
     192                                                                hours <
     193                                                                fs2.
     194                                                                ftimeLastWrite.
     195                                                                hours) ? 1
     196            : (fs1.ftimeLastWrite.hours >
     197               fs2.ftimeLastWrite.hours) ? -1 : (fs1.ftimeLastWrite.minutes <
     198                                                 fs2.ftimeLastWrite.
     199                                                 minutes) ? 1 : (fs1.
     200                                                                 ftimeLastWrite.
     201                                                                 minutes >
     202                                                                 fs2.
     203                                                                 ftimeLastWrite.
     204                                                                 minutes) ? -1
     205            : (fs1.ftimeLastWrite.twosecs <
     206               fs2.ftimeLastWrite.twosecs) ? 1 : (fs1.ftimeLastWrite.twosecs >
     207                                                  fs2.ftimeLastWrite.
     208                                                  twosecs) ? -1 : 0;
     209          sourcesmaller =
     210            (fs1.cbFile < fs2.cbFile) ? -1 : (fs1.cbFile >
     211                                              fs2.cbFile) ? 1 : 0;
     212          sprintf(&s[strlen(s)], GetPString(IDS_SOURCEISTEXT),
     213                  (sourcenewer ==
     214                   -1) ? GetPString(IDS_NEWERTEXT) : (sourcenewer ==
     215                                                      1) ?
     216                  GetPString(IDS_OLDERTEXT) : GetPString(IDS_SAMEDATETEXT),
     217                  (sourcesmaller ==
     218                   -1) ? GetPString(IDS_SMALLERTEXT) : (sourcesmaller ==
     219                                                        1) ?
     220                  GetPString(IDS_LARGERTEXT) : GetPString(IDS_SAMESIZETEXT));
     221        }
     222        WinSetDlgItemText(hwnd, REN_INFORMATION, s);
     223        if (targetexists && stricmp(mv->source, mv->target)) {
     224          if (WinQueryButtonCheckstate(hwnd, REN_DONTASK))
     225            return 0;
     226          return MRFROM2SHORT(1, 0);
     227        }
     228        else if (targetexists && !stricmp(mv->source, mv->target)) {
     229          if (mv->rename && strcmp(mv->source, mv->target))
     230            return 0;
     231          WinEnableWindow(WinWindowFromID(hwnd, REN_RENEXIST), FALSE);
     232          return MRFROM2SHORT(2, 0);
     233        }
     234      }
     235    }
     236    return 0;
     237
     238  case WM_COMMAND:
     239    switch (SHORT1FROMMP(mp1)) {
     240    case DID_CANCEL:
     241      WinDismissDlg(hwnd, 0);
     242      break;
     243
     244    case IDM_HELP:
     245      if (hwndHelp)
     246        WinSendMsg(hwndHelp,
     247                   HM_DISPLAY_HELP,
     248                   MPFROM2SHORT(HELP_RENAME, 0), MPFROMSHORT(HM_RESOURCEID));
     249      break;
     250
     251    case REN_SKIP:
     252      mv = WinQueryWindowPtr(hwnd, 0);
     253      if (mv) {
     254        mv->skip = TRUE;
     255        *mv->target = 0;
     256        WinDismissDlg(hwnd, 2);
     257      }
     258      else
     259        WinDismissDlg(hwnd, 0);
     260      break;
     261
     262    case REN_RENEXIST:
     263      mv = WinQueryWindowPtr(hwnd, 0);
     264      if (mv) {
     265
     266        CHAR newexist[CCHMAXPATH], fullname[CCHMAXPATH];
     267        INT was;
     268        APIRET rc;
     269
     270        *newexist = 0;
     271        WinQueryDlgItemText(hwnd, REN_TARGET, CCHMAXPATH, newexist);
     272        if (*newexist) {
     273          if (DosQueryPathInfo(newexist,
     274                               FIL_QUERYFULLNAME, fullname, sizeof(fullname)))
     275            strcpy(fullname, newexist);
     276          was = IsFile(fullname);
     277          if (was == -1) {
     278            rc = docopyf(MOVE, mv->target, "%s", fullname);
     279            if (rc) {
     280              if ((LONG) rc > 0)
     281                Dos_Error(MB_CANCEL,
     282                          rc,
     283                          hwnd,
     284                          __FILE__,
     285                          __LINE__,
     286                          GetPString(IDS_COMPMOVEFAILEDTEXT),
     287                          mv->target, fullname);
     288              else
     289                saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
     290                       hwnd,
     291                       GetPString(IDS_SORRYTEXT),
     292                       GetPString(IDS_COMPMOVEFAILEDTEXT),
     293                       mv->target, fullname);
     294            }
     295            else
     296              saymsg(MB_ENTER,
     297                     hwnd,
     298                     GetPString(IDS_SUCCESSTEXT),
     299                     GetPString(IDS_WASMOVEDTOTEXT), mv->target, fullname);
     300          }
     301          else
     302            saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
     303                   hwnd,
     304                   GetPString(IDS_SORRYTEXT),
     305                   GetPString(IDS_EXISTSASATEXT),
     306                   fullname,
     307                   (was) ?
     308                   GetPString(IDS_FILETEXT) : GetPString(IDS_DIRECTORYTEXT));
     309        }
     310        WinSetDlgItemText(hwnd, REN_TARGET, mv->target);
     311      }
     312      break;
     313
     314    case REN_OVERWRITE:
     315    case DID_OK:
     316      mv = WinQueryWindowPtr(hwnd, 0);
     317      if (mv) {
     318
     319        MRESULT mr;
     320
     321        if (WinQueryButtonCheckstate(hwnd, REN_DONTASK))
     322          mv->dontask = TRUE;
     323        if (WinQueryButtonCheckstate(hwnd, REN_OVEROLD))
     324          mv->overold = TRUE;
     325        if (WinQueryButtonCheckstate(hwnd, REN_OVERNEW))
     326          mv->overnew = TRUE;
     327        *mv->target = 0;
     328        WinQueryDlgItemText(hwnd, REN_TARGET, CCHMAXPATH, mv->target);
     329        bstrip(mv->target);
     330        mr = WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     331        if (!mr ||
     332            (SHORT1FROMMR(mr) != 2 && SHORT1FROMMP(mp1) == REN_OVERWRITE)) {
     333
     334          CHAR path[CCHMAXPATH], *p;
     335
     336          mv->overwrite = (SHORT1FROMMP(mp1) == REN_OVERWRITE);
     337          strcpy(path, mv->target);
     338          p = strrchr(path, '\\');
     339          if (p) {
     340            p++;
     341            *p = 0;
     342            if (SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
     343                                      QW_OWNER), hwnd, path, 0)) {
     344              DosBeep(250, 100);
     345              WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, REN_TARGET));
     346              break;
     347            }
     348          }
     349          WinDismissDlg(hwnd, 1);
     350        }
     351        else {
     352          DosBeep(250, 100);
     353          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, REN_TARGET));
     354        }
     355      }
     356      break;
     357    }
     358    return 0;
    404359  }
    405   return WinDefDlgProc(hwnd,msg,mp1,mp2);
     360  return WinDefDlgProc(hwnd, msg, mp1, mp2);
    406361}
    407 
Note: See TracChangeset for help on using the changeset viewer.