unrarsrc  6.1.7
About: unrar extracts, views and tests the contents of archives created with the RAR archiver.
  Fossies Dox: unrarsrc-6.1.7.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

uicommon.cpp
Go to the documentation of this file.
2
4{
5 uiSoundNotify = Sound;
6}
7
8
9// Additionally to handling user input, it analyzes and sets command options.
10// Returns only 'replace', 'skip' and 'cancel' codes.
11UIASKREP_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 {
40 return UIASKREP_R_REPLACE;
41 }
42 if (Choice==UIASKREP_R_SKIPALL)
43 {
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 {
61 return UIASKREP_R_REPLACE;
62 }
63#endif
64 return Choice;
65}
bool AllYes
Definition: options.hpp:152
OVERWRITE_MODE Overwrite
Definition: options.hpp:130
bool GetAutoRenamedName(wchar *Name, size_t MaxNameSize)
Definition: filcreat.cpp:59
void PrepareToDelete(const wchar *Name)
Definition: filefn.cpp:264
bool FileExist(const wchar *Name)
Definition: filefn.cpp:190
@ OVERWRITE_NONE
Definition: options.hpp:43
@ OVERWRITE_AUTORENAME
Definition: options.hpp:44
@ OVERWRITE_ALL
Definition: options.hpp:42
SOUND_NOTIFY_MODE
Definition: options.hpp:75
wchar * PointToName(const wchar *Path)
Definition: pathfn.cpp:3
void SetName(wchar *FullName, const wchar *Name, size_t MaxSize)
Definition: pathfn.cpp:67
#define ASIZE(x)
Definition: rardefs.hpp:10
wchar_t wchar
Definition: rartypes.hpp:13
int64_t int64
Definition: rartypes.hpp:12
unsigned int uint
Definition: rartypes.hpp:8
void wcsncpyz(wchar *dest, const wchar *src, size_t maxlen)
Definition: strfn.cpp:275
UIASKREP_RESULT uiAskReplace(wchar *Name, size_t MaxNameSize, int64 FileSize, RarTime *FileTime, uint Flags)
Definition: uiconsole.cpp:4
UIASKREP_RESULT
Definition: ui.hpp:74
@ UIASKREP_R_RENAME
Definition: ui.hpp:76
@ UIASKREP_R_SKIP
Definition: ui.hpp:75
@ UIASKREP_R_RENAMEAUTO
Definition: ui.hpp:76
@ UIASKREP_R_SKIPALL
Definition: ui.hpp:75
@ UIASKREP_R_REPLACEALL
Definition: ui.hpp:75
@ UIASKREP_R_REPLACE
Definition: ui.hpp:75
void uiInit(SOUND_NOTIFY_MODE Sound)
Definition: uicommon.cpp:3
static SOUND_NOTIFY_MODE uiSoundNotify
Definition: uicommon.cpp:1
UIASKREP_RESULT uiAskReplaceEx(RAROptions *Cmd, wchar *Name, size_t MaxNameSize, int64 FileSize, RarTime *FileTime, uint Flags)
Definition: uicommon.cpp:11