uicommon.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. static SOUND_NOTIFY_MODE uiSoundNotify;
  2. void uiInit(SOUND_NOTIFY_MODE Sound)
  3. {
  4. uiSoundNotify = Sound;
  5. }
  6. // Additionally to handling user input, it analyzes and sets command options.
  7. // Returns only 'replace', 'skip' and 'cancel' codes.
  8. UIASKREP_RESULT uiAskReplaceEx(RAROptions *Cmd,wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags)
  9. {
  10. if (Cmd->Overwrite==OVERWRITE_NONE)
  11. return UIASKREP_R_SKIP;
  12. #if !defined(SFX_MODULE) && !defined(SILENT)
  13. // Must be before Cmd->AllYes check or -y switch would override -or.
  14. if (Cmd->Overwrite==OVERWRITE_AUTORENAME && GetAutoRenamedName(Name,MaxNameSize))
  15. return UIASKREP_R_REPLACE;
  16. #endif
  17. // This check must be after OVERWRITE_AUTORENAME processing or -y switch
  18. // would override -or.
  19. if (Cmd->AllYes || Cmd->Overwrite==OVERWRITE_ALL)
  20. {
  21. PrepareToDelete(Name);
  22. return UIASKREP_R_REPLACE;
  23. }
  24. wchar NewName[NM];
  25. wcsncpyz(NewName,Name,ASIZE(NewName));
  26. UIASKREP_RESULT Choice=uiAskReplace(NewName,ASIZE(NewName),FileSize,FileTime,Flags);
  27. if (Choice==UIASKREP_R_REPLACE || Choice==UIASKREP_R_REPLACEALL)
  28. PrepareToDelete(Name);
  29. if (Choice==UIASKREP_R_REPLACEALL)
  30. {
  31. Cmd->Overwrite=OVERWRITE_ALL;
  32. return UIASKREP_R_REPLACE;
  33. }
  34. if (Choice==UIASKREP_R_SKIPALL)
  35. {
  36. Cmd->Overwrite=OVERWRITE_NONE;
  37. return UIASKREP_R_SKIP;
  38. }
  39. if (Choice==UIASKREP_R_RENAME)
  40. {
  41. if (PointToName(NewName)==NewName)
  42. SetName(Name,NewName,MaxNameSize);
  43. else
  44. wcsncpyz(Name,NewName,MaxNameSize);
  45. if (FileExist(Name))
  46. return uiAskReplaceEx(Cmd,Name,MaxNameSize,FileSize,FileTime,Flags);
  47. return UIASKREP_R_REPLACE;
  48. }
  49. #if !defined(SFX_MODULE) && !defined(SILENT)
  50. if (Choice==UIASKREP_R_RENAMEAUTO && GetAutoRenamedName(Name,MaxNameSize))
  51. {
  52. Cmd->Overwrite=OVERWRITE_AUTORENAME;
  53. return UIASKREP_R_REPLACE;
  54. }
  55. #endif
  56. return Choice;
  57. }