浏览代码

Bug 1575: Cannot enter subfolders of local drive mapped to WebDAV folder

https://winscp.net/tracker/1575

Source commit: 3d2b0a48d854f345528acaa2f9ee888e9f15ccbe
Martin Prikryl 8 年之前
父节点
当前提交
927c8ed95e

+ 1 - 24
source/packages/filemng/BaseUtils.pas

@@ -36,7 +36,6 @@ type
   TFormatBytesStyle = (fbNone, fbKilobytes, fbShort);
   TFormatBytesStyle = (fbNone, fbKilobytes, fbShort);
 
 
 function CheckFileExists(FileName: string): Boolean;
 function CheckFileExists(FileName: string): Boolean;
-function DirExists(Dir: string): Boolean; overload;
 function ExtractFileNameOnly(Name: string): string;
 function ExtractFileNameOnly(Name: string): string;
 function FileOrDirExists(FileName: string): Boolean;
 function FileOrDirExists(FileName: string): Boolean;
 function FormatBytes(Bytes: Int64; Style: TFormatBytesStyle = fbShort; UseUnitsForBytes: Boolean = True): string;
 function FormatBytes(Bytes: Int64; Style: TFormatBytesStyle = fbShort; UseUnitsForBytes: Boolean = True): string;
@@ -120,15 +119,8 @@ begin
 end; {StringCountains}
 end; {StringCountains}
 
 
 function FileOrDirExists(FileName: string): Boolean;
 function FileOrDirExists(FileName: string): Boolean;
-var
-  SRec : TSearchRec;
 begin
 begin
-  if Length(FileName) = 0 then Result := False
-    else
-  begin
-    Result := (FindFirst(ApiPath(FileName), faAnyFile, SRec) = 0);
-    SysUtils.FindCLose(SRec);
-  end;
+  Result := FileExists(FileName) or DirectoryExists(FileName);
 end; {FileOrDirExists}
 end; {FileOrDirExists}
 
 
 function CheckFileExists(FileName: string): Boolean;
 function CheckFileExists(FileName: string): Boolean;
@@ -149,21 +141,6 @@ begin
   end;
   end;
 end; {CheckFileExists}
 end; {CheckFileExists}
 
 
-function DirExists(Dir: string): Boolean;
-var
-  SRec: TSearchRec;
-begin
-  Result := ((Length(Dir) <= 3) and (Length(Dir) >= 2)) and (Dir[2] = ':');
-  if not Result then
-  begin
-    if FindFirst(ApiPath(Dir), faAnyFile, SRec) = 0 then
-    begin
-      Result := (SRec.Attr and faDirectory <> 0);
-    end;
-    SysUtils.FindClose(SRec);
-  end;
-end; {DirExists}
-
 function ExtractFileNameOnly(Name: string): string;
 function ExtractFileNameOnly(Name: string): string;
 var
 var
   Ext: string;
   Ext: string;

+ 8 - 8
source/packages/filemng/DirView.pas

@@ -1192,7 +1192,7 @@ begin
       else FDriveType := DRIVE_UNKNOWN;
       else FDriveType := DRIVE_UNKNOWN;
 
 
     FDirOK := (Length(FPath) > 0) and
     FDirOK := (Length(FPath) > 0) and
-      DriveInfo[FPath[1]].DriveReady and DirExists(FPath);
+      DriveInfo[FPath[1]].DriveReady and DirectoryExists(FPath);
 
 
     if DirOK then
     if DirOK then
     begin
     begin
@@ -1312,7 +1312,7 @@ begin
     if IsRecycleBin then Reload(True)
     if IsRecycleBin then Reload(True)
       else
       else
     begin
     begin
-      if not DirExists(Path) then
+      if not DirectoryExists(Path) then
       begin
       begin
         ClearItems;
         ClearItems;
         FDirOK := False;
         FDirOK := False;
@@ -1871,7 +1871,7 @@ begin
       NextItem := GetNextItem(Item, sdAll, [isSelected]);
       NextItem := GetNextItem(Item, sdAll, [isSelected]);
       case PFileRec(Item.Data)^.IsDirectory of
       case PFileRec(Item.Data)^.IsDirectory of
         True:
         True:
-          if not DirExists(ItemFullFileName(Item)) then
+          if not DirectoryExists(ItemFullFileName(Item)) then
           begin
           begin
             DirDeleted := True;
             DirDeleted := True;
             Item.Delete;
             Item.Delete;
@@ -2714,7 +2714,7 @@ begin
     if PFileRec(Item.Data)^.IsDirectory then
     if PFileRec(Item.Data)^.IsDirectory then
     begin
     begin
       FileName := ItemFullFileName(Item);
       FileName := ItemFullFileName(Item);
-      if not DirExists(FileName) then
+      if not DirectoryExists(FileName) then
       begin
       begin
         Reload2;
         Reload2;
         if Assigned(FDriveView) and Assigned(FDriveView.Selected) then
         if Assigned(FDriveView) and Assigned(FDriveView.Selected) then
@@ -2726,7 +2726,7 @@ begin
       else
       else
     FileName := ResolveFileShortCut(ItemFullFileName(Item), True);
     FileName := ResolveFileShortCut(ItemFullFileName(Item), True);
 
 
-    if DirExists(FileName) then
+    if DirectoryExists(FileName) then
     begin
     begin
       Path := FileName;
       Path := FileName;
       Exit;
       Exit;
@@ -2824,7 +2824,7 @@ var
   IsDirectory: Boolean;
   IsDirectory: Boolean;
 begin
 begin
   Item := GetItemFromHItem(HItem);
   Item := GetItemFromHItem(HItem);
-  IsDirectory := DirExists(ItemFullFileName(Item));
+  IsDirectory := DirectoryExists(ItemFullFileName(Item));
   NewCaption := HItem.pszText;
   NewCaption := HItem.pszText;
 
 
   StopWatchThread;
   StopWatchThread;
@@ -3108,7 +3108,7 @@ var
 begin
 begin
   if DragDropFilesEx.FileList.Count > 0 then
   if DragDropFilesEx.FileList.Count > 0 then
   begin
   begin
-    if not DirExists(TargetPath) then
+    if not DirectoryExists(TargetPath) then
     begin
     begin
       Reload(True);
       Reload(True);
       DDError(DDPathNotFoundError);
       DDError(DDPathNotFoundError);
@@ -3152,7 +3152,7 @@ begin
 
 
               if SourcePath = '' then
               if SourcePath = '' then
               begin
               begin
-                if DirExists(TFDDListItem(DragDropFilesEx.FileList[Index]^).Name) then
+                if DirectoryExists(TFDDListItem(DragDropFilesEx.FileList[Index]^).Name) then
                 begin
                 begin
                   SourcePath := TFDDListItem(DragDropFilesEx.FileList[Index]^).Name;
                   SourcePath := TFDDListItem(DragDropFilesEx.FileList[Index]^).Name;
                   SourceIsDirectory := True;
                   SourceIsDirectory := True;

+ 6 - 6
source/packages/filemng/DriveView.pas

@@ -797,7 +797,7 @@ end;
 
 
 function TDriveView.NodePathExists(Node: TTreeNode): Boolean;
 function TDriveView.NodePathExists(Node: TTreeNode): Boolean;
 begin
 begin
-  Result := DirExists(NodePathName(Node));
+  Result := DirectoryExists(NodePathName(Node));
 end;
 end;
 
 
 function TDriveView.CanEdit(Node: TTreeNode): Boolean;
 function TDriveView.CanEdit(Node: TTreeNode): Boolean;
@@ -962,7 +962,7 @@ begin
   {Create the drive nodes:}
   {Create the drive nodes:}
   RefreshRootNodes(dsDisplayName or dvdsFloppy);
   RefreshRootNodes(dsDisplayName or dvdsFloppy);
   {Set the initial directory:}
   {Set the initial directory:}
-  if (Length(FDirectory) > 0) and DirExists(FDirectory) then
+  if (Length(FDirectory) > 0) and DirectoryExists(FDirectory) then
     Directory := FDirectory;
     Directory := FDirectory;
 
 
   FCreating := False;
   FCreating := False;
@@ -1093,7 +1093,7 @@ begin
 
 
           if DriveReady then
           if DriveReady then
           begin
           begin
-            if not DirExists(NewDir) then
+            if not DirectoryExists(NewDir) then
             begin
             begin
               ValidateDirectory(DriveStatus[Upcase(NewDir[1])].RootNode);
               ValidateDirectory(DriveStatus[Upcase(NewDir[1])].RootNode);
               Exit;
               Exit;
@@ -1686,7 +1686,7 @@ begin {CallBackValidateDir}
 
 
   {Check, if directory still exists: (but not with root directory) }
   {Check, if directory still exists: (but not with root directory) }
   if Assigned(Node.Parent) and (PScanDirInfo(Data)^.StartNode = Node) then
   if Assigned(Node.Parent) and (PScanDirInfo(Data)^.StartNode = Node) then
-    if not DirExists(NodePathName(Node)) then
+    if not DirectoryExists(NodePathName(Node)) then
     begin
     begin
       WorkNode := Node.Parent;
       WorkNode := Node.Parent;
       if Selected = Node then
       if Selected = Node then
@@ -1935,13 +1935,13 @@ begin
       FileOperator.Flags := FileOperator.Flags + [foNoConfirmation];
       FileOperator.Flags := FileOperator.Flags + [foNoConfirmation];
 
 
     try
     try
-      if DirExists(DelDir) then
+      if DirectoryExists(DelDir) then
       begin
       begin
         StopWatchThread;
         StopWatchThread;
         OperatorResult := FileOperator.Execute;
         OperatorResult := FileOperator.Execute;
 
 
         if OperatorResult and (not FileOperator.OperationAborted) and
         if OperatorResult and (not FileOperator.OperationAborted) and
-           (not DirExists(DelDir)) then
+           (not DirectoryExists(DelDir)) then
         begin
         begin
           Node.Delete
           Node.Delete
         end
         end

+ 3 - 11
source/packages/my/ComboEdit.pas

@@ -408,14 +408,6 @@ begin
   if Result then Result := Pos('\', ExtractFileName(FileName)) = 0;
   if Result then Result := Pos('\', ExtractFileName(FileName)) = 0;
 end;
 end;
 
 
-function DirExists(Name: string): Boolean;
-var
-  Code: Integer;
-begin
-  Code := GetFileAttributes(PChar(ApiPath(Name)));
-  Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
-end;
-
 { TCustomComboEdit }
 { TCustomComboEdit }
 
 
 constructor TCustomComboEdit.Create(AOwner: TComponent);
 constructor TCustomComboEdit.Create(AOwner: TComponent);
@@ -970,7 +962,7 @@ begin
   if not Action then Exit;
   if not Action then Exit;
   if ValidFileName(Temp) then
   if ValidFileName(Temp) then
     try
     try
-      if DirExists(ExtractFilePath(Temp)) then
+      if DirectoryExists(ExtractFilePath(Temp)) then
         SetInitialDir(ExtractFilePath(Temp));
         SetInitialDir(ExtractFilePath(Temp));
       if (ExtractFileName(Temp) = '') or
       if (ExtractFileName(Temp) = '') or
         not ValidFileName(ExtractFileName(Temp)) then Temp := '';
         not ValidFileName(ExtractFileName(Temp)) then Temp := '';
@@ -1140,7 +1132,7 @@ begin
     if (InitialDir <> '') then Temp := InitialDir
     if (InitialDir <> '') then Temp := InitialDir
     else Temp := '\';
     else Temp := '\';
   end;
   end;
-  if not DirExists(Temp) then Temp := '\';
+  if not DirectoryExists(Temp) then Temp := '\';
   DisableSysErrors;
   DisableSysErrors;
   try
   try
     Action := SelectDirectory(FDialogText, '', Temp);
     Action := SelectDirectory(FDialogText, '', Temp);
@@ -1153,7 +1145,7 @@ begin
     SelText := '';
     SelText := '';
     if (Text = '') or not MultipleDirs then Text := Temp
     if (Text = '') or not MultipleDirs then Text := Temp
     else Text := Text + ';' + Temp;
     else Text := Text + ';' + Temp;
-    if (Temp <> '') and DirExists(Temp) then InitialDir := Temp;
+    if (Temp <> '') and DirectoryExists(Temp) then InitialDir := Temp;
   end;
   end;
 end;
 end;