MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / uiAskReplaceEx

Function uiAskReplaceEx

Libraries/unrar/uicommon.cpp:11–65  ·  view source on GitHub ↗

Additionally to handling user input, it analyzes and sets command options. Returns only 'replace', 'skip' and 'cancel' codes.

Source from the content-addressed store, hash-verified

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 {
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}

Callers 1

FileCreateFunction · 0.85

Calls 7

GetAutoRenamedNameFunction · 0.85
PrepareToDeleteFunction · 0.85
wcsncpyzFunction · 0.85
PointToNameFunction · 0.85
SetNameFunction · 0.85
FileExistFunction · 0.85
uiAskReplaceFunction · 0.70

Tested by

no test coverage detected