Browse Source

Bug 2000: Empty local drive could not be entered

https://winscp.net/tracker/2000
(cherry picked from commit bc689d11d02fec260234096d30d956334fda7bf3)

Source commit: 9f1230b3c2a7bb18064ca706e0640da9269182a9
Martin Prikryl 4 years ago
parent
commit
664784ef76
1 changed files with 6 additions and 2 deletions
  1. 6 2
      source/packages/filemng/DirView.pas

+ 6 - 2
source/packages/filemng/DirView.pas

@@ -624,13 +624,17 @@ begin
   if not DirectoryExistsFix(Path) then
   if not DirectoryExistsFix(Path) then
     raise Exception.CreateFmt(SDirNotExists, [Path]);
     raise Exception.CreateFmt(SDirNotExists, [Path]);
   DosError := SysUtils.FindFirst(ApiPath(IncludeTrailingPathDelimiter(Path) + '*.*'), FileAttr, SRec);
   DosError := SysUtils.FindFirst(ApiPath(IncludeTrailingPathDelimiter(Path) + '*.*'), FileAttr, SRec);
-  if DosError = 0 then
+  if DosError = ERROR_SUCCESS then
   begin
   begin
     FindClose(SRec);
     FindClose(SRec);
   end
   end
     else
     else
   begin
   begin
-    RaiseLastOSError;
+    // File not found is expected when accessing a root folder of an empty drive
+    if DosError <> ERROR_FILE_NOT_FOUND then
+    begin
+      RaiseLastOSError;
+    end;
   end;
   end;
 end;
 end;