ftplistmain.pas 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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: 13708: ftplistmain.pas
  11. {
  12. { Rev 1.12 2/17/2003 11:14:46 PM JPMugaas
  13. { Updated for new system determination type. For Cisco IOS and TOPS20, we have
  14. { to cheat by providing a system descriptor.
  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 ftplistmain;
  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. for i := 0 to s.Count -1 do
  132. begin
  133. if Pos('TOPS20',ExtractFileName(edtFileName.Text))=1 then
  134. begin
  135. LDirectoryListing.ListFormat := LDirectoryListing.CheckListFormat(s[i],TRUE,'TOPS20');
  136. end
  137. else
  138. begin
  139. if Pos('Cisco-',ExtractFileName(edtFileName.Text))=1 then
  140. begin
  141. LDirectoryListing.ListFormat := LDirectoryListing.CheckListFormat(s[i],TRUE,'Cisco IOS ');
  142. end
  143. else
  144. begin
  145. LDirectoryListing.ListFormat := LDirectoryListing.CheckListFormat(s[i],TRUE);
  146. end;
  147. end;
  148. if LDirectoryListing.ListFormat <> flfNextLine then
  149. begin
  150. Break;
  151. end;
  152. end;
  153. LDirectoryListing.LoadList(s);
  154. d.Assign(s);
  155. d.Add('==============================');
  156. for i := 0 to LDirectoryListing.Count -1 do
  157. begin
  158. d.Add('File Name: '+LDirectoryListing[i].FileName);
  159. d.Add('Local File Name: '+LDirectoryListing[i].LocalFileName);
  160. d.Add('File Owner: '+LDirectoryListing[i].OwnerName);
  161. case LDirectoryListing.ListFormat of
  162. flfNovelNetware,
  163. flfNovelNetwarePSU_DOS,
  164. flfHellSoft :
  165. d.Add('Insider Premissions: '+ LDirectoryListing[i].NovellPermissions );
  166. flfUnix : ;
  167. flfVMS :
  168. begin
  169. d.Add('System Protections: '+LDirectoryListing[i].VMSSystemPermissions);
  170. d.Add('Owner Protections: '+LDirectoryListing[i].VMSOwnerPermissions);
  171. d.Add('Group Protections: '+LDirectoryListing[i].VMSGroupPermissions);
  172. d.Add('World Protections: '+LDirectoryListing[i].VMSWorldPermissions );
  173. end;
  174. flfVMCMS, flfMusic,flfMVS :
  175. begin
  176. d.Add('Volume: '+LDirectoryListing[i].MVSVolume);
  177. d.Add('Unit: '+LDirectoryListing[i].MVSUnit);
  178. d.Add('Record Length: '+IntToStr(LDirectoryListing[i].RecLength ));
  179. d.Add('Number of Records: '+IntToStr(LDirectoryListing[i].NumberRecs ));
  180. if LDirectoryListing.ListFormat = flfMVS then
  181. begin
  182. d.Add('Record Format: '+LDirectoryListing[i].RecFormat);
  183. d.Add('Number of Extents: '+IntToStr(LDirectoryListing[i].MVSNumberExtents ));
  184. d.Add('Number of Tracks: '+IntToStr(LDirectoryListing[i].MVSNumberTracks ));
  185. end;
  186. d.Add('Number of Blocks: '+IntToStr(LDirectoryListing[i].NumberBlocks ));
  187. d.Add('Block Size: '+IntToStr(LDirectoryListing[i].BlockSize ));
  188. if LDirectoryListing[i].MVSDSOrg <> '' then
  189. begin
  190. d.Add('Data Set Organization: '+LDirectoryListing[i].MVSDSOrg);
  191. end;
  192. end;
  193. flfMVS_JES, flfMVS_JESIntf2 :
  194. begin
  195. case LDirectoryListing[i].MVSJobStatus of
  196. IdJESReceived : d.Add('Job Status: Received');
  197. IdJESHold : d.Add('Job Status: Hold');
  198. IdJESRunning : d.Add('Job Status: Running');
  199. IdJESOuptutAvailable :
  200. begin
  201. d.Add('Job Status: Output Available');
  202. d.Add('Spool Files: '+ IntToStr( LDirectoryListing[i].MVSJobSpoolFiles ));
  203. end;
  204. end;
  205. end;
  206. end;
  207. if LDirectoryListing.ListFormat in [flfVMS, flfUnix] then
  208. begin
  209. d.Add('File Group: '+LDirectoryListing[i].GroupName);
  210. end;
  211. d.Add('File Size: '+IntToStr(LDirectoryListing[i].Size ));
  212. case LDirectoryListing[i].ItemType of
  213. ditDirectory : d.Add('File Type: Directory');
  214. ditFile : d.Add('File Type: File');
  215. ditSymbolicLink : d.Add('File Type: Symbolic Link');
  216. ditSymbolicLinkDir : d.Add('File Type: Symbolic Link to Dir');
  217. end;
  218. if LDirectoryListing[i].ModifiedDate <> 0 then
  219. begin
  220. d.Add('Last Modified Date: '+DateTimeToStr( LDirectoryListing[i].ModifiedDate ));
  221. end;
  222. if LDirectoryListing[i].ModifiedDateGMT <> 0 then
  223. begin
  224. d.Add('Last Modified Date GMT: '+DateTimeToStr( LDirectoryListing[i].ModifiedDateGMT ));
  225. end;
  226. d.Add('Item Count: '+IntToStr(LDirectoryListing[i].ItemCount ));
  227. d.Add('');
  228. end;
  229. if edtOutputFileName.Text = '' then
  230. begin
  231. mmoTestLog.Lines.Assign(d);
  232. end
  233. else
  234. begin
  235. d.SaveToFile(edtOutputFileName.Text);
  236. end;
  237. finally
  238. FreeAndNil(s);
  239. FreeAndNil(d);
  240. end;
  241. finally
  242. FreeAndNil( LDirectoryListing );
  243. end;
  244. end;
  245. procedure TForm1.btnOBrowseClick(Sender: TObject);
  246. begin
  247. sdlgOutput.FileName := edtOutputFileName.Text;
  248. if odlgTestList.Execute then
  249. begin
  250. edtOutputFileName.Text := sdlgOutput.FileName;
  251. end;
  252. end;
  253. end.