Przeglądaj źródła

Better error message when trying to open an inaccessible local drive (such as locked BitLocker drive)

Source commit: a357dec5c5648317ccb71fca807b54bebd9f19dd
Martin Prikryl 11 miesięcy temu
rodzic
commit
8a1a22320b
1 zmienionych plików z 7 dodań i 1 usunięć
  1. 7 1
      source/packages/filemng/DirView.pas

+ 7 - 1
source/packages/filemng/DirView.pas

@@ -606,7 +606,13 @@ var
   SRec: SysUtils.TSearchRec;
 begin
   if not DirectoryExistsFix(Path) then
-    raise Exception.CreateFmt(SDirNotExists, [Path]);
+  begin
+    DosError := GetLastError;
+    if (DosError = ERROR_FILE_NOT_FOUND) or (DosError = ERROR_PATH_NOT_FOUND) then
+      raise Exception.CreateFmt(SDirNotExists, [Path])
+    else
+      RaiseLastOSError;
+  end;
   DosError := SysUtils.FindFirst(ApiPath(IncludeTrailingPathDelimiter(Path) + '*.*'), FileAttr, SRec);
   if DosError = ERROR_SUCCESS then
   begin