1
0
Эх сурвалжийг харах

Bug 1905: Allow explicit navigation to a hidden local folder by enabling showing of hidden files and folder, if not enabled yet

https://winscp.net/tracker/1905

Source commit: 0fd234bbe9fa47cb811082bd3e340355c7df0fd5
Martin Prikryl 5 жил өмнө
parent
commit
dd1128215e

+ 9 - 0
source/forms/ScpCommander.cpp

@@ -2553,3 +2553,12 @@ void __fastcall TScpCommanderForm::UpdateRemotePathComboBox(bool TextOnly)
     LocalPathComboUpdate(OtherLocalDirView, RemotePathComboBox);
   }
 }
+//---------------------------------------------------------------------------
+void __fastcall TScpCommanderForm::LocalDriveViewNeedHiddenDirectories(TObject *)
+{
+  if (DebugAlwaysTrue(!WinConfiguration->ShowHiddenFiles))
+  {
+    ToggleShowHiddenFiles();
+  }
+}
+//---------------------------------------------------------------------------

+ 2 - 0
source/forms/ScpCommander.dfm

@@ -1194,6 +1194,7 @@ inherited ScpCommanderForm: TScpCommanderForm
         TabOrder = 1
         TabStop = False
         OnEnter = OtherLocalDriveViewEnter
+        OnNeedHiddenDirectories = LocalDriveViewNeedHiddenDirectories
       end
       inherited RemoteDriveView: TUnixDriveView
         Width = 280
@@ -1766,6 +1767,7 @@ inherited ScpCommanderForm: TScpCommanderForm
       TabOrder = 2
       TabStop = False
       OnEnter = LocalDriveViewEnter
+      OnNeedHiddenDirectories = LocalDriveViewNeedHiddenDirectories
     end
     object LocalBottomDock: TTBXDock
       Left = 0

+ 1 - 0
source/forms/ScpCommander.h

@@ -503,6 +503,7 @@ __published:
   void __fastcall OtherLocalDirViewContextPopup(TObject *Sender, TPoint &MousePos, bool &Handled);
   void __fastcall OtherLocalDirViewUpdateStatusBar(TObject *Sender, const TStatusFileInfo &FileInfo);
   void __fastcall OtherLocalDirViewPathChange(TCustomDirView *Sender);
+  void __fastcall LocalDriveViewNeedHiddenDirectories(TObject *Sender);
 
 private:
   bool FConstructed;

+ 29 - 0
source/packages/filemng/DriveView.pas

@@ -141,6 +141,7 @@ type
     {Additional events:}
     FOnDisplayContextMenu: TNotifyEvent;
     FOnRefreshDrives: TNotifyEvent;
+    FOnNeedHiddenDirectories: TNotifyEvent;
 
     {used components:}
     FDirView: TDirView;
@@ -388,6 +389,7 @@ type
     property OnMouseUp;
     property OnStartDock;
     property OnStartDrag;
+    property OnNeedHiddenDirectories: TNotifyEvent read FOnNeedHiddenDirectories write FOnNeedHiddenDirectories;
   end;
 
 procedure Register;
@@ -2185,7 +2187,34 @@ begin
 end; {SetAutoScan}
 
 function TDriveView.FindPathNode(Path: string): TTreeNode;
+var
+  PossiblyHiddenPath: string;
+  Attrs: Integer;
 begin
+  if Assigned(FOnNeedHiddenDirectories) and
+     (not ShowHiddenDirs) and
+     DirectoryExistsFix(Path) then // do not even bother if the path does not exist
+  begin
+    PossiblyHiddenPath := ExcludeTrailingPathDelimiter(Path);
+    while (PossiblyHiddenPath <> '') and
+          (not IsRootPath(PossiblyHiddenPath)) do // Drives have hidden attribute
+    begin
+      Attrs := FileGetAttr(PossiblyHiddenPath, False);
+      if (Attrs and faHidden) = faHidden then
+      begin
+        if Assigned(FOnNeedHiddenDirectories) then
+        begin
+          FOnNeedHiddenDirectories(Self);
+        end;
+        Break;
+      end
+        else
+      begin
+        PossiblyHiddenPath := ExtractFileDir(PossiblyHiddenPath);
+      end;
+    end;
+  end;
+
   {Find existing path or parent path of not existing path:}
   repeat
     Result := FindNodeToPath(Path);