1
0

Symlink.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //---------------------------------------------------------------------------
  2. #include <FormsPCH.h>
  3. #pragma hdrstop
  4. #include "Symlink.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. //---------------------------------------------------------------------------
  9. bool __fastcall DoSymlinkDialog(UnicodeString & FileName, UnicodeString & PointTo,
  10. TOperationSide Side, bool & SymbolicLink, bool Edit, bool AllowHardLink)
  11. {
  12. bool Result;
  13. TSymlinkDialog * Dialog = new TSymlinkDialog(Application);
  14. try
  15. {
  16. Dialog->FileName = FileName;
  17. Dialog->PointTo = PointTo;
  18. Dialog->Side = Side;
  19. Dialog->SymbolicLink = SymbolicLink;
  20. Dialog->Edit = Edit;
  21. Dialog->AllowHardLink = AllowHardLink;
  22. Result = Dialog->Execute();
  23. if (Result)
  24. {
  25. FileName = Dialog->FileName;
  26. PointTo = Dialog->PointTo;
  27. SymbolicLink = Dialog->SymbolicLink;
  28. }
  29. }
  30. __finally
  31. {
  32. delete Dialog;
  33. }
  34. return Result;
  35. }
  36. //---------------------------------------------------------------------------
  37. __fastcall TSymlinkDialog::TSymlinkDialog(TComponent* Owner)
  38. : TForm(Owner)
  39. {
  40. UseSystemSettings(this);
  41. FSide = osLocal;
  42. }
  43. //---------------------------------------------------------------------------
  44. void __fastcall TSymlinkDialog::UpdateControls()
  45. {
  46. DebugAssert(Side == osLocal || Side == osRemote);
  47. FileNameEdit->Color = !Edit ? clWindow : clBtnFace;
  48. FileNameEdit->ReadOnly = Edit;
  49. FileNameEdit->TabStop = !Edit;
  50. EnableControl(HardLinkCheck, (Side == osRemote) && !Edit && AllowHardLink);
  51. EnableControl(OkButton, !FileName.IsEmpty() && !PointTo.IsEmpty());
  52. }
  53. //---------------------------------------------------------------------------
  54. void __fastcall TSymlinkDialog::SetFileName(UnicodeString value)
  55. {
  56. FileNameEdit->Text = value;
  57. }
  58. //---------------------------------------------------------------------------
  59. UnicodeString __fastcall TSymlinkDialog::GetFileName()
  60. {
  61. return FileNameEdit->Text;
  62. }
  63. //---------------------------------------------------------------------------
  64. void __fastcall TSymlinkDialog::SetPointTo(UnicodeString value)
  65. {
  66. PointToEdit->Text = value;
  67. }
  68. //---------------------------------------------------------------------------
  69. UnicodeString __fastcall TSymlinkDialog::GetPointTo()
  70. {
  71. return PointToEdit->Text;
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TSymlinkDialog::SetSymbolicLink(bool value)
  75. {
  76. HardLinkCheck->Checked = !value;
  77. }
  78. //---------------------------------------------------------------------------
  79. bool __fastcall TSymlinkDialog::GetSymbolicLink()
  80. {
  81. return !HardLinkCheck->Checked;
  82. }
  83. //---------------------------------------------------------------------------
  84. void __fastcall TSymlinkDialog::SetSide(TOperationSide value)
  85. {
  86. FSide = value;
  87. UpdateControls();
  88. }
  89. //---------------------------------------------------------------------------
  90. void __fastcall TSymlinkDialog::SetEdit(bool value)
  91. {
  92. FEdit = value;
  93. UpdateControls();
  94. }
  95. //---------------------------------------------------------------------------
  96. void __fastcall TSymlinkDialog::ControlChange(TObject * /*Sender*/)
  97. {
  98. UpdateControls();
  99. }
  100. //---------------------------------------------------------------------------
  101. void __fastcall TSymlinkDialog::SetAllowHardLink(bool value)
  102. {
  103. FAllowHardLink = value;
  104. UpdateControls();
  105. }
  106. //---------------------------------------------------------------------------
  107. bool __fastcall TSymlinkDialog::Execute()
  108. {
  109. return (ShowModal() == DefaultResult(this));
  110. }
  111. //---------------------------------------------------------------------------
  112. void __fastcall TSymlinkDialog::FormShow(TObject * /*Sender*/)
  113. {
  114. InstallPathWordBreakProc(PointToEdit);
  115. InstallPathWordBreakProc(FileNameEdit);
  116. Caption = LoadStr(Edit ? LINK_EDIT_CAPTION : LINK_ADD_CAPTION);
  117. UpdateControls();
  118. }
  119. //---------------------------------------------------------------------------
  120. void __fastcall TSymlinkDialog::HelpButtonClick(TObject * /*Sender*/)
  121. {
  122. FormHelp(this);
  123. }
  124. //---------------------------------------------------------------------------