ftplistmainMLSD.pas 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. { $HDR$}
  2. {**********************************************************************}
  3. { Unit archived using Team Coherence }
  4. { Team Coherence is Copyright 2002 by Quality Software Components }
  5. { }
  6. { For further information / comments, visit our WEB site at }
  7. { http://www.TeamCoherence.com }
  8. {**********************************************************************}
  9. {}
  10. { $Log: 16040: ftplistmainMLSD.pas
  11. {
  12. { Rev 1.0 2/13/2003 03:04:14 PM JPMugaas
  13. { Box tests and capture program for MLSD output. We handle that separately
  14. { from regular LIST data.
  15. }
  16. {
  17. { Rev 1.11 1/26/2003 02:33:54 AM JPMugaas
  18. { Reworked for some property changes and for additional MVS properties.
  19. }
  20. {
  21. { Rev 1.10 1/25/2003 07:32:44 PM JPMugaas
  22. { Expanded for MUSIC support.
  23. }
  24. {
  25. { Rev 1.9 1/24/2003 01:51:34 AM JPMugaas
  26. }
  27. {
  28. { Rev 1.8 1/4/2003 03:35:30 PM JPMugaas
  29. { MVS JES interface 1 and 2 specific properties.
  30. }
  31. {
  32. { Rev 1.7 1/4/2003 03:26:22 PM JPMugaas
  33. { MVS JES queue properties now displayed for JES interface 1.
  34. }
  35. {
  36. { Rev 1.6 1/4/2003 01:31:46 PM JPMugaas
  37. { Updated for new parser restructure and additions.
  38. }
  39. {
  40. { Rev 1.5 12/29/2002 10:24:08 PM JPMugaas
  41. { Updated for some new properties. Widened the columns output for the box test
  42. { to accomodate a longer feildname.
  43. }
  44. {
  45. { Rev 1.4 12/11/2002 03:38:46 PM JPMugaas
  46. { Added LocalFileName test.
  47. }
  48. {
  49. { Rev 1.3 12/11/2002 03:24:36 AM JPMugaas
  50. { Reworked the parsing code to be more consistant with the special dir case
  51. { indicating NextLine.
  52. }
  53. {
  54. { Rev 1.2 12/10/2002 10:13:28 AM JPMugaas
  55. { Logging TMemo bottom anchor fixed.
  56. }
  57. {
  58. { Rev 1.1 12/9/2002 06:53:56 PM JPMugaas
  59. { Added support for new dir type. Set the anchors for the log TMemo. It was
  60. { just a small thing that was driving me nuts.
  61. }
  62. {
  63. { Rev 1.0 11/13/2002 04:01:12 PM JPMugaas
  64. }
  65. unit ftplistmainMLSD;
  66. interface
  67. uses
  68. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  69. Dialogs, StdCtrls;
  70. type
  71. TForm1 = class(TForm)
  72. mmoTestLog: TMemo;
  73. btnTest: TButton;
  74. edtFileName: TEdit;
  75. lblFileName: TLabel;
  76. bbtnBrowse: TButton;
  77. odlgTestList: TOpenDialog;
  78. edtOutputFileName: TEdit;
  79. lblOutputFileName: TLabel;
  80. btnOBrowse: TButton;
  81. sdlgOutput: TSaveDialog;
  82. procedure FormCreate(Sender: TObject);
  83. procedure bbtnBrowseClick(Sender: TObject);
  84. procedure btnTestClick(Sender: TObject);
  85. procedure btnOBrowseClick(Sender: TObject);
  86. private
  87. { Private declarations }
  88. public
  89. { Public declarations }
  90. end;
  91. var
  92. Form1: TForm1;
  93. implementation
  94. uses IdFTPList;
  95. {$R *.dfm}
  96. procedure TForm1.FormCreate(Sender: TObject);
  97. begin
  98. odlgTestList.InitialDir := ExtractFilePath(ParamStr(0));
  99. end;
  100. procedure TForm1.bbtnBrowseClick(Sender: TObject);
  101. begin
  102. odlgTestList.FileName := edtFileName.Text;
  103. if odlgTestList.Execute then
  104. begin
  105. edtFileName.Text := odlgTestList.FileName;
  106. end;
  107. end;
  108. procedure TForm1.btnTestClick(Sender: TObject);
  109. var s, d : TStrings;
  110. i : Integer;
  111. LDirectoryListing : TIdFTPListItems;
  112. begin
  113. mmoTestLog.Lines.Clear;
  114. LDirectoryListing := TIdFTPListItems.Create;
  115. try
  116. s := TStringList.Create;
  117. d := TStringList.Create;
  118. try
  119. s.LoadFromFile(edtFileName.Text );
  120. // Parse directory listing
  121. for i := s.Count -1 downto 0 do
  122. begin
  123. if (s[i]<>'') and (s[i][1] = '#') then
  124. begin
  125. s.Delete(i);
  126. end;
  127. end;
  128. //we do things this way because some servers will return blank lines
  129. //or something such as TOTAL x which we can not use for determining the format
  130. LDirectoryListing.ListFormat := flfNextLine;
  131. LDirectoryListing.ListFormat := flfMLS;
  132. LDirectoryListing.LoadMList(s);
  133. d.Assign(s);
  134. d.Add('==============================');
  135. for i := 0 to LDirectoryListing.Count -1 do
  136. begin
  137. d.Add('File Name: '+LDirectoryListing[i].FileName);
  138. d.Add('Local File Name: '+LDirectoryListing[i].LocalFileName);
  139. d.Add('File Owner: '+LDirectoryListing[i].OwnerName);
  140. case LDirectoryListing.ListFormat of
  141. flfNovelNetware,
  142. flfNovelNetwarePSU_DOS,
  143. flfHellSoft :
  144. d.Add('Insider Premissions: '+ LDirectoryListing[i].NovellPermissions );
  145. flfUnix : ;
  146. flfVMS :
  147. begin
  148. d.Add('System Protections: '+LDirectoryListing[i].VMSSystemPermissions);
  149. d.Add('Owner Protections: '+LDirectoryListing[i].VMSOwnerPermissions);
  150. d.Add('Group Protections: '+LDirectoryListing[i].VMSGroupPermissions);
  151. d.Add('World Protections: '+LDirectoryListing[i].VMSWorldPermissions );
  152. end;
  153. flfVMCMS, flfMusic,flfMVS :
  154. begin
  155. d.Add('Volume: '+LDirectoryListing[i].MVSVolume);
  156. d.Add('Unit: '+LDirectoryListing[i].MVSUnit);
  157. d.Add('Record Length: '+IntToStr(LDirectoryListing[i].RecLength ));
  158. d.Add('Number of Records: '+IntToStr(LDirectoryListing[i].NumberRecs ));
  159. if LDirectoryListing.ListFormat = flfMVS then
  160. begin
  161. d.Add('Record Format: '+LDirectoryListing[i].RecFormat);
  162. d.Add('Number of Extents: '+IntToStr(LDirectoryListing[i].MVSNumberExtents ));
  163. d.Add('Number of Tracks: '+IntToStr(LDirectoryListing[i].MVSNumberTracks ));
  164. end;
  165. d.Add('Number of Blocks: '+IntToStr(LDirectoryListing[i].NumberBlocks ));
  166. d.Add('Block Size: '+IntToStr(LDirectoryListing[i].BlockSize ));
  167. if LDirectoryListing[i].MVSDSOrg <> '' then
  168. begin
  169. d.Add('Data Set Organization: '+LDirectoryListing[i].MVSDSOrg);
  170. end;
  171. end;
  172. flfMVS_JES, flfMVS_JESIntf2 :
  173. begin
  174. case LDirectoryListing[i].MVSJobStatus of
  175. IdJESReceived : d.Add('Job Status: Received');
  176. IdJESHold : d.Add('Job Status: Hold');
  177. IdJESRunning : d.Add('Job Status: Running');
  178. IdJESOuptutAvailable :
  179. begin
  180. d.Add('Job Status: Output Available');
  181. d.Add('Spool Files: '+ IntToStr( LDirectoryListing[i].MVSJobSpoolFiles ));
  182. end;
  183. end;
  184. end;
  185. end;
  186. if LDirectoryListing.ListFormat in [flfVMS, flfUnix] then
  187. begin
  188. d.Add('File Group: '+LDirectoryListing[i].GroupName);
  189. end;
  190. d.Add('File Size: '+IntToStr(LDirectoryListing[i].Size ));
  191. case LDirectoryListing[i].ItemType of
  192. ditDirectory : d.Add('File Type: Directory');
  193. ditFile : d.Add('File Type: File');
  194. ditSymbolicLink : d.Add('File Type: Symbolic Link');
  195. ditSymbolicLinkDir : d.Add('File Type: Symbolic Link to Dir');
  196. end;
  197. if LDirectoryListing[i].ModifiedDate <> 0 then
  198. begin
  199. d.Add('Last Modified Date: '+DateTimeToStr( LDirectoryListing[i].ModifiedDate ));
  200. end;
  201. if LDirectoryListing[i].ModifiedDateGMT <> 0 then
  202. begin
  203. d.Add('Last Modified Date GMT: '+DateTimeToStr( LDirectoryListing[i].ModifiedDateGMT ));
  204. end;
  205. d.Add('Item Count: '+IntToStr(LDirectoryListing[i].ItemCount ));
  206. d.Add('');
  207. end;
  208. if edtOutputFileName.Text = '' then
  209. begin
  210. mmoTestLog.Lines.Assign(d);
  211. end
  212. else
  213. begin
  214. d.SaveToFile(edtOutputFileName.Text);
  215. end;
  216. finally
  217. FreeAndNil(s);
  218. FreeAndNil(d);
  219. end;
  220. finally
  221. FreeAndNil( LDirectoryListing );
  222. end;
  223. end;
  224. procedure TForm1.btnOBrowseClick(Sender: TObject);
  225. begin
  226. sdlgOutput.FileName := edtOutputFileName.Text;
  227. if odlgTestList.Execute then
  228. begin
  229. edtOutputFileName.Text := sdlgOutput.FileName;
  230. end;
  231. end;
  232. end.