浏览代码

ADD: Show error message when user tries to change a target location (issue #2327)

Alexander Koblov 3 月之前
父节点
当前提交
4800956d1f
共有 2 个文件被更改,包括 11 次插入1 次删除
  1. 10 1
      src/fmain.pas
  2. 1 0
      src/ulng.pas

+ 10 - 1
src/fmain.pas

@@ -3711,6 +3711,15 @@ begin
           Exit;
 
         params.targetPath := CopyDialog.edtDst.Text;
+        BaseDir := ExtractFilePath(params.targetPath);
+
+        // Path was removed and target filesource is not equal to source filesource
+        if (Length(BaseDir) = 0) and (not params.targetFS.Equals(params.sourceFS)) then
+        begin
+          MessageDlg(rsMsgInvalidPath, rsMsgCannotChangeTarget, mtError, [mbOK], 0);
+          Exit;
+        end;
+
         FileSourceManager.confirmOperation( params );
 
         if SourceFileSource.IsClass(TArchiveFileSource) then
@@ -3724,7 +3733,7 @@ begin
                                   BaseDir, TargetPath, sDstMaskTemp);
         params.resultTargetPath:= TargetPath;
 
-        if (TargetFileSource = nil) or (Length(params.resultTargetPath) = 0) then
+        if (params.targetFS = nil) or (Length(params.resultTargetPath) = 0) then
         begin
           MessageDlg(rsMsgInvalidPath, rsMsgErrNotSupported, mtWarning, [mbOK], 0);
           Continue;

+ 1 - 0
src/ulng.pas

@@ -43,6 +43,7 @@ resourcestring
   rsMsgFileExistsRwrt = 'File %s exists, overwrite?';
   rsMsgFileChangedSave = 'File %s changed, save?';
   rsMsgReplaceThisText = 'Do you want to replace this text?';
+  rsMsgCannotChangeTarget = 'You cannot change a target location!';
   rsMsgCancelOperation = 'Are you sure that you want to cancel this operation?';
   rsMsgFileReloadWarning = 'Are you sure you want to reload the current file and lose the changes?';
   rsMsgFolderExistsRwrt = 'Folder %s exists, merge?';