UPD: When copying/moving files optionally skip setting properties that failed to be set.

This commit is contained in:
cobines 2012-04-18 10:43:12 +00:00
commit ca153148dd
5 changed files with 30 additions and 23 deletions

View file

@ -34,12 +34,12 @@ const
ResponseToButton: array[TFileSourceOperationUIResponse] of TMyMsgButton =
(msmbOK, msmbOK, msmbNo, msmbYes, msmbCancel, msmbNone, msmbAppend, msmbResume,
msmbCopyInto, msmbCopyIntoAll, msmbOverwrite, msmbOverwriteAll, msmbOverwriteOlder,
msmbSkip, msmbSkipAll, msmbAll, msmbRetry, msmbAbort);
msmbSkip, msmbSkipAll, msmbIgnoreAll, msmbAll, msmbRetry, msmbAbort);
ResultToResponse: array[TMyMsgResult] of TFileSourceOperationUIResponse =
(fsourOk, fsourNo, fsourYes, fsourCancel, fsourNone, fsourAppend, fsourResume,
fsourCopyInto, fsourCopyIntoAll, fsourOverwrite, fsourOverwriteAll, fsourOverwriteOlder,
fsourSkip, fsourSkipAll, fsourAll, fsourRetry, fsourAbort);
fsourSkip, fsourSkipAll, fsourIgnoreAll, fsourAll, fsourRetry, fsourAbort);
constructor TFileSourceOperationMessageBoxesUI.Create;
begin

View file

@ -25,6 +25,7 @@ type
fsourOverwriteOlder,
fsourSkip,
fsourSkipAll,
fsourIgnoreAll,
fsourAll,
fsourRetry,
fsourAbort);

View file

@ -906,27 +906,31 @@ var
CopyAttrResult: TCopyAttributesOptions;
Msg: String = '';
begin
CopyAttrResult := mbFileCopyAttr(SourceFileName, TargetFileName, FCopyAttributesOptions);
if (CopyAttrResult <> []) and not FSkipSetPropertiesError then
if FCopyAttributesOptions <> [] then
begin
if caoCopyAttributes in CopyAttrResult then
AddStrWithSep(Msg, Format(rsMsgErrSetAttribute, [SourceFileName]), LineEnding);
if caoCopyTime in CopyAttrResult then
AddStrWithSep(Msg, Format(rsMsgErrSetDateTime, [SourceFileName]), LineEnding);
if caoCopyOwnership in CopyAttrResult then
AddStrWithSep(Msg, Format(rsMsgErrSetOwnership, [SourceFileName]), LineEnding);
CopyAttrResult := mbFileCopyAttr(SourceFileName, TargetFileName, FCopyAttributesOptions);
if (CopyAttrResult <> []) and not FSkipSetPropertiesError then
begin
if caoCopyAttributes in CopyAttrResult then
AddStrWithSep(Msg, Format(rsMsgErrSetAttribute, [SourceFileName]), LineEnding);
if caoCopyTime in CopyAttrResult then
AddStrWithSep(Msg, Format(rsMsgErrSetDateTime, [SourceFileName]), LineEnding);
if caoCopyOwnership in CopyAttrResult then
AddStrWithSep(Msg, Format(rsMsgErrSetOwnership, [SourceFileName]), LineEnding);
case AskQuestion(Msg, '',
[fsourSkip, fsourSkipAll, fsourAbort],
fsourSkip, fsourSkip) of
fsourAbort:
AbortOperation;
//fsourSkip: do nothing
fsourSkipAll:
begin
case AskQuestion(Msg, '',
[fsourSkip, fsourSkipAll, fsourIgnoreAll, fsourAbort],
fsourSkip, fsourIgnoreAll) of
//fsourSkip: do nothing
fsourSkipAll:
// Don't set properties that failed to be set anymore.
FCopyAttributesOptions := FCopyAttributesOptions - CopyAttrResult;
fsourIgnoreAll:
FSkipSetPropertiesError := True;
end;
end; // case
fsourAbort:
AbortOperation;
end;
end;
end;
end;

View file

@ -24,12 +24,12 @@ type
TMyMsgResult=(mmrOK, mmrNo, mmrYes, mmrCancel, mmrNone,
mmrAppend, mmrResume, mmrCopyInto, mmrCopyIntoAll,
mmrOverwrite, mmrOverwriteAll, mmrOverwriteOlder, mmrSkip,
mmrSkipAll, mmrAll, mmrRetry, mmrAbort);
mmrSkipAll, mmrIgnoreAll, mmrAll, mmrRetry, mmrAbort);
TMyMsgButton=(msmbOK, msmbNo, msmbYes, msmbCancel, msmbNone,
msmbAppend, msmbResume, msmbCopyInto, msmbCopyIntoAll,
msmbOverwrite, msmbOverwriteAll, msmbOverwriteOlder, msmbSkip,
msmbSkipAll, msmbAll, msmbRetry, msmbAbort);
msmbSkipAll, msmbIgnoreAll, msmbAll, msmbRetry, msmbAbort);
{ TDialogMainThread }
@ -496,6 +496,7 @@ begin
cLngButton[msmbOverwriteOlder] := rsDlgButtonOverwriteOlder;
cLngButton[msmbSkip] := rsDlgButtonSkip;
cLngButton[msmbSkipAll] := rsDlgButtonSkipAll;
cLngButton[msmbIgnoreAll] := rsDlgButtonIgnoreAll;
cLngButton[msmbAll] := rsDlgButtonAll;
cLngButton[msmbRetry] := rsDlgButtonRetry;
cLngButton[msmbAbort] := rsDlgButtonAbort;

View file

@ -173,6 +173,7 @@ resourcestring
rsDlgButtonOverwriteOlder = 'Overwrite All Ol&der';
rsDlgButtonSkip = '&Skip';
rsDlgButtonSkipAll = 'S&kip All';
rsDlgButtonIgnoreAll = 'I&gnore All';
rsDlgButtonAll = 'A&ll';
rsDlgButtonRetry = 'Re&try';
rsDlgButtonAbort = 'Ab&ort';