UnixDriveView.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <Common.h>
  5. #include "UnixDriveView.h"
  6. #ifndef DESIGN_ONLY
  7. #include <Terminal.h>
  8. #include <RemoteFiles.h>
  9. #endif
  10. #pragma package(smart_init)
  11. //---------------------------------------------------------------------------
  12. static inline void ValidCtrCheck(TUnixDriveView *)
  13. {
  14. new TUnixDriveView(NULL);
  15. }
  16. //---------------------------------------------------------------------------
  17. namespace Unixdriveview
  18. {
  19. void __fastcall PACKAGE Register()
  20. {
  21. TComponentClass classes[1] = {__classid(TUnixDriveView)};
  22. RegisterComponents("Scp", classes, 0);
  23. }
  24. }
  25. //---------------------------------------------------------------------------
  26. __fastcall TUnixDriveView::TUnixDriveView(TComponent * Owner) :
  27. TCustomUnixDriveView(Owner)
  28. {
  29. }
  30. //---------------------------------------------------------------------------
  31. struct TNodeData
  32. {
  33. TRemoteFileList * FileList;
  34. TRemoteFile * File;
  35. AnsiString Directory;
  36. };
  37. //---------------------------------------------------------------------------
  38. __fastcall TCustomUnixDriveView::TCustomUnixDriveView(TComponent* Owner) :
  39. TCustomDriveView(Owner)
  40. {
  41. FTerminal = NULL;
  42. FRootName = DEFAULT_ROOTNAME;
  43. FIgnoreChange = false;
  44. FPrevSelected = NULL;
  45. DDAllowMove = false;
  46. FShowInaccesibleDirectories = true;
  47. FDummyDragFile = NULL;
  48. }
  49. //---------------------------------------------------------------------------
  50. __fastcall TCustomUnixDriveView::~TCustomUnixDriveView()
  51. {
  52. Terminal = NULL;
  53. if (FDummyDragFile != NULL)
  54. {
  55. #ifndef DESIGN_ONLY
  56. SAFE_DESTROY(FDummyDragFile);
  57. #endif
  58. }
  59. }
  60. //---------------------------------------------------------------------------
  61. void __fastcall TCustomUnixDriveView::CreateWnd()
  62. {
  63. TCustomDriveView::CreateWnd();
  64. FDragDropFilesEx->TargetEffects = TDropEffectSet() << deCopy << deMove;
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TCustomUnixDriveView::SetTerminal(TTerminal * value)
  68. {
  69. if (FTerminal != value)
  70. {
  71. FTerminal = value;
  72. Items->Clear();
  73. }
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TCustomUnixDriveView::SetDirView(TUnixDirView * Value)
  77. {
  78. if (FDirView != Value)
  79. {
  80. if (FDirView != NULL)
  81. {
  82. FDirView->DriveView = NULL;
  83. }
  84. FDirView = Value;
  85. if (FDirView != NULL)
  86. {
  87. FDirView->DriveView = this;
  88. }
  89. }
  90. }
  91. //---------------------------------------------------------------------------
  92. TCustomDirView * __fastcall TCustomUnixDriveView::GetCustomDirView()
  93. {
  94. return FDirView;
  95. }
  96. //---------------------------------------------------------------------------
  97. void __fastcall TCustomUnixDriveView::SetCustomDirView(TCustomDirView * Value)
  98. {
  99. SetDirView(dynamic_cast<TUnixDirView *>(Value));
  100. }
  101. //---------------------------------------------------------------------------
  102. bool __fastcall TCustomUnixDriveView::IsRootNameStored()
  103. {
  104. return (FRootName != DEFAULT_ROOTNAME);
  105. }
  106. //---------------------------------------------------------------------------
  107. bool __fastcall TCustomUnixDriveView::NodeIsHidden(const TTreeNode * Node)
  108. {
  109. #ifndef DESIGN_ONLY
  110. TNodeData * Data = NodeData(Node);
  111. TRemoteFile * File = Data->File;
  112. return
  113. ((File != NULL) && File->IsHidden) ||
  114. ((File == NULL) && IsUnixHiddenFile(UnixExtractFileName(Data->Directory)));
  115. #else
  116. return false;
  117. #endif
  118. }
  119. //---------------------------------------------------------------------------
  120. bool __fastcall TCustomUnixDriveView::NodeCanDelete(TTreeNode * Node)
  121. {
  122. return (Selected == NULL) ||
  123. ((Selected != Node) && !Selected->HasAsParent(Node));
  124. }
  125. //---------------------------------------------------------------------------
  126. void __fastcall TCustomUnixDriveView::UpdatePath(TTreeNode * Node, bool Force,
  127. bool CanLoad)
  128. {
  129. #ifndef DESIGN_ONLY
  130. TNodeData * Data = NodeData(Node);
  131. AnsiString Path = Data->Directory;
  132. if (FTerminal->DirectoryFileList(Path, Data->FileList, CanLoad) ||
  133. ((Data->FileList != NULL) && Force))
  134. {
  135. TStringList * ChildrenDirs = new TStringList();
  136. try
  137. {
  138. ChildrenDirs->Sorted = true;
  139. ChildrenDirs->Duplicates = dupAccept;
  140. ChildrenDirs->CaseSensitive = true;
  141. bool HadChildren = (Node->Count > 0);
  142. if (HadChildren)
  143. {
  144. for (int i = 0; i < Node->Count; i++)
  145. {
  146. TTreeNode * ChildNode = Node->Item[i];
  147. TNodeData * ChildData = NodeData(ChildNode);
  148. ChildData->File = NULL;
  149. ChildrenDirs->AddObject(UnixExtractFileName(ChildData->Directory),
  150. ChildNode);
  151. }
  152. }
  153. for (int i = 0; i < Data->FileList->Count; i++)
  154. {
  155. TRemoteFile * File = Data->FileList->Files[i];
  156. if (File->IsDirectory && !File->IsParentDirectory && !File->IsThisDirectory &&
  157. (ShowHiddenDirs || !File->IsHidden) &&
  158. (ShowInaccesibleDirectories || !File->IsInaccesibleDirectory))
  159. {
  160. int ChildIndex = ChildrenDirs->IndexOf(File->FileName);
  161. if (ChildIndex >= 0)
  162. {
  163. TTreeNode * ChildNode =
  164. dynamic_cast<TTreeNode *>(ChildrenDirs->Objects[ChildIndex]);
  165. TNodeData * ChildData = NodeData(ChildNode);
  166. ChildData->File = File;
  167. UpdatePath(ChildNode, Force);
  168. }
  169. else
  170. {
  171. AnsiString ChildPath = UnixIncludeTrailingBackslash(Path) + File->FileName;
  172. assert(!IsUnixRootPath(ChildPath));
  173. LoadPathEasy(Node, ChildPath, File);
  174. }
  175. }
  176. }
  177. if (HadChildren)
  178. {
  179. for (int i = 0; i < ChildrenDirs->Count; i++)
  180. {
  181. TTreeNode * ChildNode = dynamic_cast<TTreeNode *>(ChildrenDirs->Objects[i]);
  182. TNodeData * ChildData = NodeData(ChildNode);
  183. if ((ChildData->File == NULL) && NodeCanDelete(ChildNode))
  184. {
  185. ChildNode->Delete();
  186. }
  187. }
  188. }
  189. Node->AlphaSort(false);
  190. }
  191. __finally
  192. {
  193. delete ChildrenDirs;
  194. }
  195. }
  196. else if (Force)
  197. {
  198. for (int i = Node->Count - 1; i >= 0; i--)
  199. {
  200. TTreeNode * ChildNode = Node->Item[i];
  201. TRemoteFile * File = NodeFile(ChildNode);
  202. if (!NodeCanDelete(ChildNode) ||
  203. ((ShowHiddenDirs || !NodeIsHidden(ChildNode)) &&
  204. (ShowInaccesibleDirectories || (File == NULL) || !File->IsInaccesibleDirectory)))
  205. {
  206. UpdatePath(ChildNode, true);
  207. }
  208. else
  209. {
  210. ChildNode->Delete();
  211. }
  212. }
  213. }
  214. #endif
  215. }
  216. //---------------------------------------------------------------------------
  217. TTreeNode * __fastcall TCustomUnixDriveView::LoadPathEasy(TTreeNode * Parent,
  218. AnsiString Path, TRemoteFile * File)
  219. {
  220. #ifndef DESIGN_ONLY
  221. assert(Path == UnixExcludeTrailingBackslash(Path));
  222. AnsiString DirName = IsUnixRootPath(Path) ? RootName : UnixExtractFileName(Path);
  223. TTreeNode * Node = Items->AddChild(Parent, DirName);
  224. TNodeData * Data = new TNodeData();
  225. Node->Data = Data;
  226. Data->Directory = Path;
  227. Data->File = File;
  228. Data->FileList = NULL;
  229. UpdatePath(Node, true);
  230. return Node;
  231. #else
  232. return NULL;
  233. #endif
  234. }
  235. //---------------------------------------------------------------------------
  236. TTreeNode * __fastcall TCustomUnixDriveView::LoadPath(AnsiString Path)
  237. {
  238. #ifndef DESIGN_ONLY
  239. if (Path.IsEmpty())
  240. {
  241. Path = ROOTDIRECTORY;
  242. }
  243. TTreeNode * Node = FindNodeToPath(Path);
  244. if (Node == NULL)
  245. {
  246. Path = UnixExcludeTrailingBackslash(Path);
  247. TTreeNode * Parent = NULL;
  248. TRemoteFile * File = NULL;
  249. if (!IsUnixRootPath(Path))
  250. {
  251. Parent = LoadPath(UnixExtractFileDir(Path));
  252. }
  253. Node = FindNodeToPath(Path);
  254. if (Node == NULL)
  255. {
  256. // node still does not exist, this should happen only when
  257. // if the parent directory is not in cache
  258. if (Parent != NULL)
  259. {
  260. TRemoteFileList * ParentFileList = NodeFileList(Parent);
  261. if (ParentFileList != NULL)
  262. {
  263. File = ParentFileList->FindFile(UnixExtractFileName(Path));
  264. }
  265. }
  266. Node = LoadPathEasy(Parent, Path, File);
  267. if (Parent != NULL)
  268. {
  269. Parent->AlphaSort(false);
  270. }
  271. }
  272. else
  273. {
  274. UpdatePath(Node, false);
  275. }
  276. }
  277. else
  278. {
  279. UpdatePath(Node, false);
  280. }
  281. return Node;
  282. #else
  283. return NULL;
  284. #endif
  285. }
  286. //---------------------------------------------------------------------------
  287. void __fastcall TCustomUnixDriveView::LoadDirectory()
  288. {
  289. #ifndef DESIGN_ONLY
  290. assert(!FIgnoreChange);
  291. FIgnoreChange = true;
  292. try
  293. {
  294. Selected = LoadPath(FTerminal->Files->Directory);
  295. assert(Selected != NULL);
  296. FPrevSelected = Selected;
  297. }
  298. __finally
  299. {
  300. FIgnoreChange = false;
  301. FDirectoryLoaded = true;
  302. }
  303. #endif
  304. }
  305. //---------------------------------------------------------------------------
  306. TNodeData * __fastcall TCustomUnixDriveView::NodeData(const TTreeNode * Node)
  307. {
  308. assert(Node->Data != NULL);
  309. return static_cast<TNodeData*>(Node->Data);
  310. }
  311. //---------------------------------------------------------------------------
  312. TRemoteFileList * __fastcall TCustomUnixDriveView::NodeFileList(const TTreeNode * Node)
  313. {
  314. assert(Node->Data != NULL);
  315. return static_cast<TNodeData*>(Node->Data)->FileList;
  316. }
  317. //---------------------------------------------------------------------------
  318. TRemoteFile * __fastcall TCustomUnixDriveView::NodeFile(const TTreeNode * Node)
  319. {
  320. assert(Node->Data != NULL);
  321. return static_cast<TNodeData*>(Node->Data)->File;
  322. }
  323. //---------------------------------------------------------------------------
  324. TRemoteFile * __fastcall TCustomUnixDriveView::NodeFileForce(TTreeNode * Node)
  325. {
  326. TRemoteFile * File = NodeFile(Node);
  327. if (File == NULL)
  328. {
  329. #ifndef DESIGN_ONLY
  330. SAFE_DESTROY(FDummyDragFile);
  331. FDummyDragFile = new TRemoteDirectoryFile();
  332. FDummyDragFile->FileName = Node->Text;
  333. FDummyDragFile->FullFileName = NodePathName(Node);
  334. File = FDummyDragFile;
  335. #endif
  336. }
  337. return File;
  338. }
  339. //---------------------------------------------------------------------------
  340. void __fastcall TCustomUnixDriveView::Delete(TTreeNode * Node)
  341. {
  342. TNodeData * Data = NULL;
  343. if (Node != NULL)
  344. {
  345. Data = NodeData(Node);
  346. }
  347. TCustomDriveView::Delete(Node);
  348. // delete file list at last, when we are sure that no child nodes exist
  349. if (Data != NULL)
  350. {
  351. #ifndef DESIGN_ONLY
  352. delete Data->FileList;
  353. #endif
  354. delete Data;
  355. }
  356. }
  357. //---------------------------------------------------------------------------
  358. void __fastcall TCustomUnixDriveView::Change(TTreeNode * Node)
  359. {
  360. #ifndef DESIGN_ONLY
  361. // During D&D Selected is set to NULL and then back to previous selection,
  362. // prevent actually changing directory in such case
  363. if (FIgnoreChange || (Node == NULL) || (Node == FPrevSelected))
  364. {
  365. TCustomDriveView::Change(Node);
  366. }
  367. else
  368. {
  369. FDirectoryLoaded = false;
  370. try
  371. {
  372. Terminal->ChangeDirectory(NodePathName(Node));
  373. TCustomDriveView::Change(Node);
  374. }
  375. __finally
  376. {
  377. if (FDirectoryLoaded)
  378. {
  379. FPrevSelected = Selected;
  380. }
  381. else
  382. {
  383. assert(!FIgnoreChange);
  384. FIgnoreChange = true;
  385. try
  386. {
  387. Selected = FPrevSelected;
  388. }
  389. __finally
  390. {
  391. FIgnoreChange = false;
  392. }
  393. }
  394. }
  395. }
  396. #else
  397. TCustomDriveView::Change(Node);
  398. #endif
  399. }
  400. //---------------------------------------------------------------------------
  401. void __fastcall TCustomUnixDriveView::PerformDragDropFileOperation(
  402. TTreeNode * Node, int Effect)
  403. {
  404. if (OnDDFileOperation)
  405. {
  406. assert(DragDropFilesEx->FileList->Count > 0);
  407. assert(Node != NULL);
  408. AnsiString SourceDirectory;
  409. AnsiString TargetDirectory;
  410. SourceDirectory = ExtractFilePath(DragDropFilesEx->FileList->Items[0]->Name);
  411. TargetDirectory = NodeData(Node)->Directory;
  412. bool DoFileOperation = true;
  413. OnDDFileOperation(this, Effect, SourceDirectory, TargetDirectory,
  414. DoFileOperation);
  415. }
  416. }
  417. //---------------------------------------------------------------------------
  418. void __fastcall TCustomUnixDriveView::DDChooseEffect(int KeyState, int & Effect)
  419. {
  420. if (DropTarget != NULL)
  421. {
  422. if ((KeyState & (MK_CONTROL | MK_SHIFT)) == 0)
  423. {
  424. Effect = DROPEFFECT_Copy;
  425. }
  426. }
  427. else
  428. {
  429. Effect = DROPEFFECT_None;
  430. }
  431. TCustomDriveView::DDChooseEffect(KeyState, Effect);
  432. }
  433. //---------------------------------------------------------------------------
  434. void __fastcall TCustomUnixDriveView::UpdateDropTarget()
  435. {
  436. // should never be NULL
  437. if (DropTarget != NULL)
  438. {
  439. UpdatePath(DropTarget, false, true);
  440. }
  441. }
  442. //---------------------------------------------------------------------------
  443. void __fastcall TCustomUnixDriveView::UpdateDropSource()
  444. {
  445. // DragNode may be NULL if its parent directory was reloaded as result
  446. // of D&D operation and thus all child nodes are recreated
  447. if ((DragNode != NULL) && (DragNode->Parent != NULL))
  448. {
  449. UpdatePath(DragNode->Parent, false, true);
  450. }
  451. }
  452. //---------------------------------------------------------------------------
  453. TStrings * __fastcall TCustomUnixDriveView::DragFileList()
  454. {
  455. assert(DragNode != NULL);
  456. TStrings * FileList = new TStringList();
  457. try
  458. {
  459. #ifndef DESIGN_ONLY
  460. FileList->AddObject(ExcludeTrailingBackslash(NodePathName(DragNode)),
  461. NodeFileForce(DragNode));
  462. #endif
  463. }
  464. catch(...)
  465. {
  466. delete FileList;
  467. throw;
  468. }
  469. return FileList;
  470. }
  471. //---------------------------------------------------------------------------
  472. bool __fastcall TCustomUnixDriveView::DragCompleteFileList()
  473. {
  474. return true;
  475. }
  476. //---------------------------------------------------------------------------
  477. TDropEffectSet __fastcall TCustomUnixDriveView::DDSourceEffects()
  478. {
  479. TDropEffectSet Result;
  480. Result << deCopy;
  481. if (DDAllowMove)
  482. {
  483. Result << deMove;
  484. }
  485. return Result;
  486. }
  487. //---------------------------------------------------------------------------
  488. AnsiString __fastcall TCustomUnixDriveView::NodePathName(TTreeNode * Node)
  489. {
  490. // same as NodePath
  491. return NodeData(Node)->Directory;
  492. }
  493. //---------------------------------------------------------------------------
  494. void __fastcall TCustomUnixDriveView::ClearDragFileList(TFileList * FileList)
  495. {
  496. #ifndef DESIGN_ONLY
  497. if (FDummyDragFile != NULL)
  498. {
  499. SAFE_DESTROY(FDummyDragFile);
  500. }
  501. #endif
  502. TCustomDriveView::ClearDragFileList(FileList);
  503. }
  504. //---------------------------------------------------------------------------
  505. void __fastcall TCustomUnixDriveView::AddToDragFileList(TFileList * FileList,
  506. TTreeNode * Node)
  507. {
  508. AnsiString FileName = NodePathName(Node);
  509. TRemoteFile * File = NodeFileForce(Node);
  510. if (OnDDDragFileName != NULL)
  511. {
  512. OnDDDragFileName(this, File, FileName);
  513. }
  514. FileList->AddItem(NULL, FileName);
  515. }
  516. //---------------------------------------------------------------------------
  517. AnsiString __fastcall TCustomUnixDriveView::NodePath(TTreeNode * Node)
  518. {
  519. // same as NodePathName
  520. return NodeData(Node)->Directory;
  521. }
  522. //---------------------------------------------------------------------------
  523. bool __fastcall TCustomUnixDriveView::NodeIsRecycleBin(TTreeNode * /*Node*/)
  524. {
  525. return false;
  526. }
  527. //---------------------------------------------------------------------------
  528. bool __fastcall TCustomUnixDriveView::NodePathExists(TTreeNode * /*Node*/)
  529. {
  530. return true;
  531. }
  532. //---------------------------------------------------------------------------
  533. TColor __fastcall TCustomUnixDriveView::NodeColor(TTreeNode * Node)
  534. {
  535. assert(Node != NULL);
  536. TColor Result = static_cast<TColor>(clDefaultItemColor);
  537. #ifndef DESIGN_ONLY
  538. if (FDimmHiddenDirs && !Node->Selected)
  539. {
  540. if (NodeIsHidden(Node))
  541. {
  542. Result = clGrayText;
  543. }
  544. }
  545. #endif
  546. return Result;
  547. }
  548. //---------------------------------------------------------------------------
  549. Word __fastcall TCustomUnixDriveView::NodeOverlayIndexes(TTreeNode * Node)
  550. {
  551. #ifndef DESIGN_ONLY
  552. Word Result = oiNoOverlay;
  553. // Cannot query root node for file
  554. if (Node->Parent != NULL)
  555. {
  556. TRemoteFile * File = NodeFile(Node);
  557. if ((File != NULL) && (File->IsSymLink))
  558. {
  559. // broken link cannot probably happen anyway
  560. // as broken links are treated as files
  561. Result |= File->BrokenLink ? oiBrokenLink : oiLink;
  562. }
  563. }
  564. return Result;
  565. #else
  566. return 0;
  567. #endif
  568. }
  569. //---------------------------------------------------------------------------
  570. void __fastcall TCustomUnixDriveView::GetImageIndex(TTreeNode * Node)
  571. {
  572. TCustomDriveView::GetImageIndex(Node);
  573. Node->ImageIndex = StdDirIcon;
  574. Node->SelectedIndex = StdDirSelIcon;
  575. }
  576. //---------------------------------------------------------------------------
  577. TTreeNode * __fastcall TCustomUnixDriveView::FindNodeToPath(AnsiString Path)
  578. {
  579. TTreeNode * Result = NULL;
  580. #ifndef DESIGN_ONLY
  581. if (IsUnixRootPath(Path))
  582. {
  583. if (Items->Count > 0)
  584. {
  585. Result = Items->Item[0];
  586. }
  587. }
  588. else
  589. {
  590. Result = NULL;
  591. Path = UnixExcludeTrailingBackslash(Path);
  592. TTreeNode * Parent = NULL;
  593. if (!IsUnixRootPath(Path))
  594. {
  595. Parent = FindNodeToPath(UnixExtractFileDir(Path));
  596. }
  597. if ((Parent != NULL) && (Parent->Count > 0))
  598. {
  599. AnsiString DirName = UnixExtractFileName(Path);
  600. int StartIndex = 0;
  601. int EndIndex = Parent->Count - 1;
  602. while (true)
  603. {
  604. int Index = (StartIndex + EndIndex) / 2;
  605. AnsiString NodeDir = Parent->Item[Index]->Text;
  606. // lstrcmp is used by AlphaSort()
  607. int C = lstrcmp(DirName.c_str(), NodeDir.c_str());
  608. if (C == 0)
  609. {
  610. Result = Parent->Item[Index];
  611. break;
  612. }
  613. else if (C < 0)
  614. {
  615. if (Index == StartIndex)
  616. {
  617. break;
  618. }
  619. EndIndex = Index - 1;
  620. }
  621. else
  622. {
  623. if (Index == EndIndex)
  624. {
  625. break;
  626. }
  627. StartIndex = Index + 1;
  628. }
  629. }
  630. }
  631. }
  632. #endif
  633. return Result;
  634. }
  635. //---------------------------------------------------------------------------
  636. TTreeNode * __fastcall TCustomUnixDriveView::FindPathNode(AnsiString Path)
  637. {
  638. TTreeNode * Result = NULL;
  639. #ifndef DESIGN_ONLY
  640. if (Items->Count > 0)
  641. {
  642. do
  643. {
  644. Result = FindNodeToPath(Path);
  645. if (Result == NULL)
  646. {
  647. assert(!IsUnixRootPath(Path));
  648. Path = UnixExtractFileDir(UnixExcludeTrailingBackslash(Path));
  649. }
  650. }
  651. while (Result == NULL);
  652. }
  653. #endif
  654. return Result;
  655. }
  656. //---------------------------------------------------------------------------
  657. void __fastcall TCustomUnixDriveView::ValidateDirectoryEx(TTreeNode * /*Node*/,
  658. TRecursiveScan /*Recurse*/, bool /*NewDirs*/)
  659. {
  660. // nothing
  661. }
  662. //---------------------------------------------------------------------------
  663. void __fastcall TCustomUnixDriveView::RebuildTree()
  664. {
  665. if (Items->Count > 0)
  666. {
  667. UpdatePath(Items->Item[0], true);
  668. }
  669. }
  670. //---------------------------------------------------------------------------
  671. void __fastcall TCustomUnixDriveView::SetShowInaccesibleDirectories(bool value)
  672. {
  673. if (FShowInaccesibleDirectories != value)
  674. {
  675. FShowInaccesibleDirectories = value;
  676. RebuildTree();
  677. }
  678. }
  679. //---------------------------------------------------------------------------
  680. void __fastcall TCustomUnixDriveView::CMShowingChanged(TMessage & Message)
  681. {
  682. TCustomDriveView::Dispatch(&Message);
  683. if (Showing && (Terminal != NULL))
  684. {
  685. LoadDirectory();
  686. }
  687. }
  688. //---------------------------------------------------------------------------
  689. void __fastcall TCustomUnixDriveView::DisplayContextMenu(TTreeNode * /*Node*/,
  690. const TPoint & /*ScreenPos*/)
  691. {
  692. // TODO
  693. }
  694. //---------------------------------------------------------------------------
  695. void __fastcall TCustomUnixDriveView::DisplayPropertiesMenu(TTreeNode * /*Node*/)
  696. {
  697. // TODO
  698. }