~ubuntu-branches/ubuntu/vivid/unrar-nonfree/vivid

« back to all changes in this revision

Viewing changes to uicommon.cpp

  • Committer: Package Import Robot
  • Author(s): Martin Meredith
  • Date: 2015-02-03 12:58:01 UTC
  • mfrom: (1.1.18) (5.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20150203125801-od6ev8cqy1er51vz
Tags: 1:5.2.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

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