Purely user interface function. Gets and returns user input.
| 1 | // Purely user interface function. Gets and returns user input. |
| 2 | UIASKREP_RESULT uiAskReplace(wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags) |
| 3 | { |
| 4 | wchar SizeText1[20],DateStr1[50],SizeText2[20],DateStr2[50]; |
| 5 | |
| 6 | FindData ExistingFD; |
| 7 | memset(&ExistingFD,0,sizeof(ExistingFD)); // In case find fails. |
| 8 | FindFile::FastFind(Name,&ExistingFD); |
| 9 | itoa(ExistingFD.Size,SizeText1,ASIZE(SizeText1)); |
| 10 | ExistingFD.mtime.GetText(DateStr1,ASIZE(DateStr1),false); |
| 11 | |
| 12 | if (FileSize==INT64NDF || FileTime==NULL) |
| 13 | { |
| 14 | eprintf(L"\n"); |
| 15 | eprintf(St(MAskOverwrite),Name); |
| 16 | } |
| 17 | else |
| 18 | { |
| 19 | itoa(FileSize,SizeText2,ASIZE(SizeText2)); |
| 20 | FileTime->GetText(DateStr2,ASIZE(DateStr2),false); |
| 21 | if ((Flags & UIASKREP_F_EXCHSRCDEST)==0) |
| 22 | eprintf(St(MAskReplace),Name,SizeText1,DateStr1,SizeText2,DateStr2); |
| 23 | else |
| 24 | eprintf(St(MAskReplace),Name,SizeText2,DateStr2,SizeText1,DateStr1); |
| 25 | } |
| 26 | |
| 27 | bool AllowRename=(Flags & UIASKREP_F_NORENAME)==0; |
| 28 | int Choice=0; |
| 29 | do |
| 30 | { |
| 31 | Choice=Ask(St(AllowRename ? MYesNoAllRenQ : MYesNoAllQ)); |
| 32 | } while (Choice==0); // 0 means invalid input. |
| 33 | switch(Choice) |
| 34 | { |
| 35 | case 1: |
| 36 | return UIASKREP_R_REPLACE; |
| 37 | case 2: |
| 38 | return UIASKREP_R_SKIP; |
| 39 | case 3: |
| 40 | return UIASKREP_R_REPLACEALL; |
| 41 | case 4: |
| 42 | return UIASKREP_R_SKIPALL; |
| 43 | } |
| 44 | if (AllowRename && Choice==5) |
| 45 | { |
| 46 | mprintf(St(MAskNewName)); |
| 47 | if (getwstr(Name,MaxNameSize)) |
| 48 | return UIASKREP_R_RENAME; |
| 49 | else |
| 50 | return UIASKREP_R_SKIP; // Process fwgets failure as if user answered 'No'. |
| 51 | } |
| 52 | return UIASKREP_R_CANCEL; |
| 53 | } |
| 54 | |
| 55 | |
| 56 |