IdFTPList.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.73 3/23/2005 5:17:36 AM JPMugaas
  18. Removed some unused stuff.
  19. Rev 1.72 2/23/2005 6:34:30 PM JPMugaas
  20. New property for displaying permissions ina GUI column. Note that this
  21. should not be used like a CHMOD because permissions are different on
  22. different platforms - you have been warned.
  23. Rev 1.71 10/26/2004 9:19:14 PM JPMugaas
  24. Fixed references.
  25. Rev 1.70 6/14/2004 12:05:50 AM JPMugaas
  26. Added support for the following Item types that appear in some Unix listings
  27. (particularly a /dev or /tmp dir):
  28. FIFO, Socket, Character Device, Block Device.
  29. Rev 1.69 4/19/2004 5:04:58 PM JPMugaas
  30. Class rework Kudzu wanted.
  31. Rev 1.68 2004.02.03 5:44:44 PM czhower
  32. Name changes
  33. Rev 1.67 24/01/2004 19:16:42 CCostelloe
  34. Cleaned up warnings
  35. Rev 1.66 1/22/2004 4:19:04 PM SPerry
  36. fixed set problems
  37. Rev 1.65 11/26/2003 6:22:12 PM JPMugaas
  38. IdFTPList can now support file creation time for MLSD servers which support
  39. that feature. I also added support for a Unique identifier for an item so
  40. facilitate some mirroring software if the server supports unique ID with EPLF
  41. and MLSD.
  42. Rev 1.64 3/9/2003 12:01:14 PM JPMugaas
  43. Now can report errors in recursive lists.
  44. Permissions work better.
  45. Rev 1.63 2/21/2003 06:54:26 PM JPMugaas
  46. The FTP list processing has been restructured so that Directory output is not
  47. done by IdFTPList. This now also uses the IdFTPListParserBase for parsing so
  48. that the code is more scalable.
  49. Rev 1.62 2/17/2003 11:10:12 PM JPMugaas
  50. Cisco IOS now supported.
  51. Rev 1.61 2/17/2003 04:43:44 PM JPMugaas
  52. TOPS20 support
  53. Rev 1.60 2/15/2003 10:29:16 AM JPMugaas
  54. Added support for some Unix specific facts with MLSD and MLST.
  55. Rev 1.59 2/14/2003 05:41:44 PM JPMugaas
  56. Moved everything from IdFTPUtils to IdFTPCommon at Kudzu's suggestion.
  57. Rev 1.58 2/13/2003 10:04:28 PM JPMugaas
  58. Moved some routines out of this unit and into a separate place so the code
  59. could be reused better.
  60. Rev 1.57 2/13/2003 01:31:56 AM JPMugaas
  61. Made sure MLSD output is valid. I also reordered the facts in the MLSD
  62. output to match with the FEAT listing.
  63. Rev 1.56 2/12/2003 12:23:44 PM JPMugaas
  64. Bug Fixes:
  65. 1) Blank line starting a recursive list.
  66. 2) The ADetails parameter was working in the opposit as it should have been.
  67. Rev 1.55 2/12/2003 07:06:06 AM JPMugaas
  68. Now honors the following parameters:
  69. x - display entrie in columns accross
  70. C - diplay entries in columns downward
  71. l - long format - standard for many FTP Servers
  72. 1 - one entry per line.
  73. Rev 1.54 2/11/2003 06:50:34 PM JPMugaas
  74. Now supports the following:
  75. -X sort by extension
  76. -S soft by file size.
  77. More consistant with NcFTP Deamon.
  78. Rev 1.53 2/11/2003 03:43:00 PM JPMugaas
  79. Q - put filename in quotes
  80. m - list files and dirs in a comma separated list
  81. are now supported.
  82. Rev 1.52 2/10/2003 03:05:14 PM JPMugaas
  83. Now can read Unix lists with both the owner and group missing. This can if
  84. the use sent the -g and -o switches.
  85. Rev 1.51 2/10/2003 02:09:28 PM JPMugaas
  86. Now can properly process dir output using -s and or -i switches. Note that
  87. Inote and Block count may not be parsed properly but it shouldn't cause an
  88. error.
  89. Rev 1.50 2/8/2003 12:43:24 PM JPMugaas
  90. BugFix: In Unix, a time is only reported if the modified date is within 6
  91. monthes of the current date. The code assumed that the time is always given
  92. if it's in the same year as the date (not always so).
  93. http://www.opengroup.org/onlinepubs/007908799/xbd/utilconv.html#usg
  94. Rev 1.49 2/8/2003 11:43:48 AM JPMugaas
  95. Made note about LineSet appearing to have two '-'. There are just two
  96. charactors that are sometimes rendered the same in some programs.
  97. Rev 1.48 2/8/2003 10:41:30 AM JPMugaas
  98. inode support for /bin/ls output.
  99. Rev 1.47 2/8/2003 04:37:16 AM JPMugaas
  100. Rewrote the dir sorting for recurive stuff so that it is more flexible and
  101. permits more sorting options. Added support for the "t" parameter and the
  102. /bin/ls "f" parameter.
  103. Rev 1.46 2/5/2003 10:13:38 PM JPMugaas
  104. Added -o, -g, -p parameter support and refined the -F parameter so executable
  105. file names are followed by a '*'.
  106. Rev 1.44 2/5/2003 02:42:10 PM JPMugaas
  107. Now supports the -r parameter for reverse-sorting lists even with recursive
  108. dirs.
  109. Rev 1.43 2/5/2003 08:43:48 AM JPMugaas
  110. Added a ExportLSSwitches property to control the output of Unix list data
  111. export. I also added support for the following switches:
  112. s - print blocks in List
  113. F - add a / to the end of dirs and symbolic links pointing to dirs
  114. A - surpress . and .. entries.
  115. The switches are the same for the /bin/ls command but we may not support them
  116. all.
  117. More will follow.
  118. Fixed a bug where the file being pointed to was not exported.
  119. Rev 1.42 2/4/2003 05:32:52 PM JPMugaas
  120. Added ability to export recursive lists in both Unix and MS-DOS styles.
  121. Rev 1.41 2/4/2003 09:35:40 AM JPMugaas
  122. Now handles Microsoft IIS DIR style with recursive listing.
  123. Fix for Recursion with NcFTP and MIcrosoft IIS in Unix DIRSTYLE mode.
  124. Fixed Novell Unix Print Services detction and Unix detection.
  125. Rev 1.40 2/3/2003 11:03:36 AM JPMugaas
  126. Now exports the directory listing into TStrings. Also made it possible to
  127. export a "total x" line for Unix style dirs.
  128. Rev 1.39 1/27/2003 02:53:18 AM JPMugaas
  129. Fixed bug that I mistakenly introduced.
  130. Rev 1.38 1/27/2003 02:09:08 AM JPMugaas
  131. Now, all permission feilds are empty at creation. If the Unix permission
  132. feilds are empty when emulating Unix, default permissions will be given.
  133. Rev 1.37 1/27/2003 01:07:44 AM JPMugaas
  134. In Unix, a list item was exported with two spaces between a year and the
  135. filename instead of one space separating both items.
  136. Rev 1.35 1/27/2003 12:16:02 AM JPMugaas
  137. Minor adjustment to the MS-DOS DIR output. It turns out that <DIR> part of
  138. the listing and the file size were off by one because only a and p were
  139. returned instead of AM/PM. In addition, the filenames were separated from
  140. the file size by two spaces instead of one space.
  141. Rev 1.34 1/26/2003 04:58:36 PM JPMugaas
  142. Expanded HP3000 parser slightly.
  143. Rev 1.33 1/26/2003 02:36:22 AM JPMugaas
  144. Removed RecType type. It was getting too ownerous to manage for MUSIC,
  145. VM/CMS, and MVS systems.
  146. Added more MVS specific properties in case a developer wishes to use them in
  147. a properties dialog-box.
  148. Rev 1.32 1/25/2003 07:31:34 PM JPMugaas
  149. Added support for MUSIC SP FTP Server.
  150. Rev 1.31 1/20/2003 04:27:24 PM JPMugaas
  151. Now handles where JES Interface 1 indicates no jobs are available.
  152. Rev 1.30 1/20/2003 03:13:06 PM JPMugaas
  153. Unix parser now works with a Axis NPS 53X FTP Printer Server.
  154. Rev 1.29 1/20/2003 12:55:06 PM JPMugaas
  155. Fixed sybmolic link detection problem I introduced when applying a patch for
  156. other file types in Unix.
  157. Rev 1.28 1/19/2003 11:10:12 PM JPMugaas
  158. Changed LoadList so it does not do anything if the FormatType is flfNextLine.
  159. Changed the Total function so it can will ignore a "Total:" so a recursive
  160. Unix listing will not ignore a "total:" subdirectory indicator.
  161. Rev 1.27 1/14/2003 04:37:52 PM JPMugaas
  162. Fixed misapplied patch for Unix parsing problem in /dev directories.
  163. Rev 1.26 1/13/2003 10:16:06 PM JPMugaas
  164. Fixed Unix parser for a peculiarity in ls output with charactor devices in
  165. the /dev hierarchy. Data submitted Jeff Eaton in
  166. Unix-ftp.netscape.com-4.txt illustrates this. Unix format check function now
  167. recognizes the following:
  168. b - block device
  169. c - character device
  170. p - pipe
  171. s - socket
  172. Rev 1.25 1/13/2003 12:21:28 AM JPMugaas
  173. Expanded comment in MVS parser to explain why we do not support file size in
  174. that format.
  175. Rev 1.24 1/12/2003 09:00:32 PM JPMugaas
  176. Refined EPLF export. The export now tries to use ModifiedDateGMT and if
  177. that's not available, it uses the ModifiedDate (assuming it's in the local
  178. timezone). EPLF requires dates to be based on GMT time.
  179. Rev 1.22 1/6/2003 10:37:12 AM JPMugaas
  180. Fixed bug with Novell Netware date interpretation. If the month was 1 and
  181. the day was 16, the Netware parser would interpret it as 1-16-2003 (note that
  182. 1-16-2003 has not yet arrived).
  183. Rev 1.21 1/4/2003 03:24:24 PM JPMugaas
  184. MVS JES Interface 1 parser now does not use string positions at all. Spacing
  185. is now used instead. More reliable that way.
  186. Rev 1.19 1/4/2003 01:38:40 PM JPMugaas
  187. Reworked HellSoft FTP Server for Novell Support and detection. Now it is
  188. detected separately from Novell Netware although it uses the same parser.
  189. Expanded Novell Netware Print Services for UNIX so DOS namespace is
  190. supported. It turned out that I mistakenly thaught that it was simply Novell
  191. Netware with a NFS namespace. Renamed format types appropriately.
  192. Rev 1.18 1/4/2003 10:53:52 AM JPMugaas
  193. Fixed parse bug in MVS. Sometimes, the first char in a filename was
  194. mistakenly dropped.
  195. Fixed MS-DOS parser. For a times such 12:15 AM, the date would be returned
  196. as 12:15 PM.
  197. Fixed a MVS Particianed Data bug. A 0 in the 3rd colum was interprettted as
  198. current date with the year 2000 if there was only a "0" in that column.
  199. Rev 1.17 1/3/2003 6:55:36 PM JPMugaas
  200. WinQVT/Net 3.98.15 support.
  201. Rev 1.16 12/30/2002 9:19:34 AM JPMugaas
  202. Patch from Andrew P. Rybin for where the count column and the file size
  203. column Unix are rammed together.
  204. Rev 1.15 12/30/2002 2:36:04 AM JPMugaas
  205. Renamed the DIstinctPermissions to DistinctAttributes because those are just
  206. the standard MS-DOS attributes (system, read-only, hidden, and archive) as
  207. verified in my notes.
  208. Refined the Distinct32 FTP server detection.
  209. Rev 1.14 12/29/2002 10:29:28 PM JPMugaas
  210. Updated Distinct Parser for a sample dir list where no year was given. Added
  211. ModifiedTimeGMT for cases where we can obtain a timestamp in GMT (Greenwhich
  212. Mean Time). These cases currently are EPLF, Distinct32, and MLST/MLSD output.
  213. Rev 1.13 12/29/2002 7:23:56 AM JPMugaas
  214. Modified VMS parser for UCX 3.3 support (VMS-Unknown-10.txt,
  215. VMS-Unknown-11.txt).
  216. Added support for Distinct TCP/IP FTP Server-32 v. 3.0.
  217. Rev 1.12 12/19/2002 03:58:16 PM JPMugaas
  218. Fixed an AV problem with a VM/CMS sample dir (case 10). It was due to a
  219. blank line that should not have been passed to the parser.
  220. Rev 1.11 12/19/2002 01:29:58 PM JPMugaas
  221. Microware OS/9 support.
  222. Rev 1.9 12/11/2002 05:52:18 PM JPMugaas
  223. Fixed MS-DOS parser. A bug would be triggered with
  224. "MS-DOS-MicrosoftFTP5.0-1.txt". The parser would locate the first 43 in a
  225. seconds portion of the dir entry instead of the file size column which also
  226. contained 43. Thanks, Jeff Easton for reporting this little gem. Also
  227. removed some unneeded variables from the MS-DOS parser.
  228. Rev 1.8 12/11/2002 03:37:06 PM JPMugaas
  229. Added LocalFileName property and the parsers now set this. This property is
  230. a suggested filename for saving the file in the local system. Pathes are
  231. removed from the FileName property and the version mark is stripped with VMS
  232. FTP Servers.
  233. Rev 1.7 12/9/2002 09:34:38 PM JPMugaas
  234. Novel Netware with NFS Volume namespace was not working as expected. A space
  235. at position in Unknown 1 and 2 was throwing things off. I simplified the
  236. logic and refined the detection further.
  237. Rev 1.6 12/9/2002 06:57:50 PM JPMugaas
  238. Added a new symbolic type for cases where a Unix server would return a / at
  239. the the end of the LinkedTo file name for a dir (clarifying if a link points
  240. to a file or a dir). If using the DIR -F, some dir names will have a / at
  241. the end and executable programs may have a * at the end. Updated the UNIX
  242. parser for new -F param. support. Note that the -F parameter is from the ls
  243. command. Most servers get dir lists simply by piping output from the /bin/ls
  244. command. NcFTP server will also simulate the ls output.
  245. Rev 1.5 12/7/2002 03:20:10 PM JPMugaas
  246. NCSA FTP server for MS-DOS - I hope. I think it is included in the Telnet
  247. package.
  248. Rev 1.4 12/6/2002 08:46:34 PM JPMugaas
  249. KA9Q Support. KA9Q is a set of Internet programs for MS-DOS including a FTP
  250. server. This was popular in the late 1980's and early 1990's. It's not in
  251. use much anymore but might be used by Ham radio operators.
  252. Rev 1.3 12/1/2002 04:20:56 PM JPMugaas
  253. added flfNextLine to handle cases where we can't determine the format of a
  254. dir with a particular line returned by the server. Expanded Unix Parser to
  255. also handle Unitree FTP servers. We now handle Unitree servers and I have
  256. verified that Unix ls -l * output now works (note that many Unix servers
  257. simply pipe output from that program).
  258. Rev 1.0 11/13/2002 08:28:58 AM JPMugaas
  259. Initial import from FTP VC.
  260. Apr.2002
  261. - Fixed bug with MSDos Listing format - space in front of file names.
  262. Sep.2001 & Jan.2002
  263. - Merged changes submitted by Andrew P.Rybin
  264. 2002 - Aug-23 - J. Peter Mugaas
  265. - fixed a parsing bug in all parsers. A file name begging with a space will
  266. throw off the parsers. Modified VMS parser to permit file names containing spaces
  267. 2002 - Aug-22 - J. Peter Mugaas
  268. - VM/CMS - now returns OwnerName - I think.
  269. - Added RecType for VM/CMS.
  270. - Renamed BlockSize to NumberBlocks. Note: Block size in VMS is usually 512 anyway
  271. (we hard-code that for a constant) and in VM/CMS, the block size is either
  272. 800, 512, 1024, 2048, or 4096 at the whim of the user and we can't get the
  273. block size from the DIR listing. In other words, any block size property is
  274. useless.
  275. - Changed VMS behvioar to be consistant with this.
  276. - Insider Privillages property added to TIdFTPListItem. This is the
  277. OwnerPermissions for Novell Netware. Note that Novell Privillages are far different
  278. than Unix permissions so they belong in a different property.
  279. - added VMS file owner and group.
  280. See: http://seqaxp.bio.caltech.edu/www/vms_beginners_faq.html#FILE00
  281. - VMS file protections (permissions).
  282. See: http://www.djesys.com/vms/freevms/mentor/vms_prot.html#prvs
  283. 2002 - Aug-20 - J. Peter Mugaas
  284. - Added Novell Netware directory parsing.
  285. - Rewrote IdFTPList Novell Netware parsing. File names with spaces are now
  286. properly handled. The code also has a side effect of stripping out a zero
  287. that occurred in a directory that was probably due to a quirk.
  288. 2002 - Aug-19 - J. Peter Mugaas
  289. - Improved VMS Directory partsing. It NO LONGER is dependant upon specific
  290. column widthes.
  291. - Fixed bugs in VM file parsing and determination.
  292. - Now handles multiline VMS file list entries.
  293. 2002 - Aug-18 - J. Peter Mugaas
  294. - VM/CMS or VM/ESA Mainframe directory format parsing added
  295. - VMS parsing added
  296. February 2001
  297. - TFTPListItem now descends from TCollectionItem
  298. - TFTPList now descends from TCollection
  299. Jun 2001
  300. - Fixes in UNIX format parser
  301. Aug 2001
  302. - It is now used in the FTP server component
  303. }
  304. unit IdFTPList;
  305. {
  306. NOTE: For this class, I recommend that you read some sections in the
  307. Operating Systems Handbook
  308. The book is out of print but is freely available at:
  309. http://www.snee.com/bob/opsys.html
  310. - Fixes as per user request for parsing non-detailed lists (SP).
  311. [Added flfNoDetails list format].
  312. Initial version by
  313. D. Siders
  314. Integral Systems
  315. October 2000
  316. Additions and extensions
  317. A Neillans
  318. Doychin Bondzhev ([email protected])
  319. dSoft-Bulgaria
  320. }
  321. interface
  322. {$i IdCompilerDefines.inc}
  323. uses
  324. Classes,
  325. IdGlobal, IdException, IdFTPCommon;
  326. { Indy TIdFtp extensions to support automatic parsing of FTP directory listings }
  327. type
  328. EIdInvalidFTPListingFormat = class(EIdException);
  329. TIdDirItemType = (ditDirectory, ditFile, ditSymbolicLink, ditSymbolicLinkDir,
  330. ditBlockDev, ditCharDev, ditFIFO, ditSocket);
  331. TIdFTPFileName = TIdUnicodeString;
  332. TIdFTPListItems = class;
  333. // TIdFTPListItem stores an item in the FTP directory listing
  334. TIdFTPListItem = class(TCollectionItem)
  335. protected
  336. FSize: Int64;
  337. FData: string;
  338. FFileName: TIdFTPFileName;
  339. FLocalFileName : TIdFTPFileName; //suggested file name for local file
  340. FSizeAvail : Boolean;
  341. FModifiedAvail : Boolean;
  342. FModifiedDate: TDateTime;
  343. //the item below is for cases such as MLST output, EPLF, and Distinct format
  344. //which usually reports dates in GMT
  345. FModifiedDateGMT : TDateTime;
  346. //Creation time values are for MLSD data output and can be returned by the
  347. //the MLSD parser in some cases
  348. FItemType: TIdDirItemType;
  349. //an error has been reported in the DIR listing itself for an item
  350. FDirError : Boolean;
  351. //Permission Display
  352. FPermissionDisplay : String;
  353. //this will very amoung platforms, do not use for CHMOD
  354. //The format veries amoung systems. This is only provided for people
  355. //wanting to display a "permission column in their FTP listing
  356. //property set methods
  357. procedure SetFileName(const AValue : TIdFTPFileName);
  358. //may be used by some descendent classes
  359. property ModifiedDateGMT : TDateTime read FModifiedDateGMT write FModifiedDateGMT;
  360. public
  361. constructor Create(AOwner: TCollection); override;
  362. procedure Assign(Source: TPersistent); override;
  363. property Data: string read FData write FData;
  364. property Size: Int64 read FSize write FSize;
  365. property ModifiedDate: TDateTime read FModifiedDate write FModifiedDate;
  366. property FileName: TIdFTPFileName read FFileName write SetFileName;
  367. property LocalFileName : TIdFTPFileName read FLocalFileName write FLocalFileName;
  368. property ItemType: TIdDirItemType read FItemType write FItemType;
  369. property SizeAvail : Boolean read FSizeAvail write FSizeAvail;
  370. property ModifiedAvail : Boolean read FModifiedAvail write FModifiedAvail;
  371. //Permission Display
  372. property PermissionDisplay : String read FPermissionDisplay write FPermissionDisplay;
  373. end;
  374. TIdFTPListOnGetCustomListFormat = procedure(AItem: TIdFTPListItem; var VText: string) of object;
  375. TIdOnParseCustomListFormat = procedure(AItem: TIdFTPListItem) of object;
  376. // TFTPList is the container and parser for items in the directory listing
  377. TIdFTPListItems = class(TCollection)
  378. protected
  379. FDirectoryName: string;
  380. //
  381. procedure SetDirectoryName(const AValue: string);
  382. function GetItems(AIndex: Integer): TIdFTPListItem;
  383. procedure SetItems(AIndex: Integer; const Value: TIdFTPListItem);
  384. public
  385. function Add: TIdFTPListItem;
  386. constructor Create; reintroduce;
  387. function IndexOf(AItem: TIdFTPListItem): Integer;
  388. property DirectoryName: string read FDirectoryName write SetDirectoryName;
  389. property Items[AIndex: Integer]: TIdFTPListItem read GetItems write SetItems; default;
  390. end;
  391. implementation
  392. uses
  393. SysUtils;
  394. { TFTPListItem }
  395. constructor TIdFTPListItem.Create(AOwner: TCollection);
  396. begin
  397. inherited Create(AOwner);
  398. Data := ''; {Do not Localize}
  399. FItemType := ditFile;
  400. Size := 0;
  401. ModifiedDate := 0.0;
  402. FFileName := ''; {Do not Localize}
  403. FLocalFileName := '';
  404. FSizeAvail := True;
  405. FModifiedAvail := True;
  406. end;
  407. procedure TIdFTPListItem.Assign(Source: TPersistent);
  408. var
  409. LSource: TIdFTPListItem;
  410. begin
  411. if Source is TIdFTPListItem then begin
  412. LSource := TIdFTPListItem(Source);
  413. Data := LSource.Data;
  414. ItemType := LSource.ItemType;
  415. Size := LSource.Size;
  416. ModifiedDate := LSource.ModifiedDate;
  417. ModifiedDateGMT := LSource.ModifiedDateGMT;
  418. FFileName := LSource.FileName;
  419. FLocalFileName := LSource.LocalFileName;
  420. SizeAvail := LSource.SizeAvail;
  421. ModifiedAvail := LSource.ModifiedAvail;
  422. PermissionDisplay := LSource.PermissionDisplay;
  423. FDirError := LSource.FDirError;
  424. end else begin
  425. inherited Assign(Source);
  426. end;
  427. end;
  428. { TFTPList }
  429. constructor TIdFTPListItems.Create;
  430. begin
  431. inherited Create(TIdFTPListItem);
  432. end;
  433. function TIdFTPListItems.Add: TIdFTPListItem;
  434. begin
  435. Result := TIdFTPListItem(inherited Add);
  436. end;
  437. function TIdFTPListItems.GetItems(AIndex: Integer): TIdFTPListItem;
  438. begin
  439. Result := TIdFTPListItem(inherited Items[AIndex]);
  440. end;
  441. function TIdFTPListItems.IndexOf(AItem: TIdFTPListItem): Integer;
  442. Var
  443. i: Integer;
  444. begin
  445. for i := 0 to Count - 1 do
  446. begin
  447. if AItem = Items[i] then
  448. begin
  449. Result := i;
  450. Exit;
  451. end;
  452. end;
  453. Result := -1;
  454. end;
  455. procedure TIdFTPListItems.SetItems(AIndex: Integer; const Value: TIdFTPListItem);
  456. begin
  457. inherited Items[AIndex] := Value;
  458. end;
  459. procedure TIdFTPListItems.SetDirectoryName(const AValue: string);
  460. begin
  461. if not TextIsSame(FDirectoryName, AValue) then begin
  462. FDirectoryName := AValue;
  463. Clear;
  464. end;
  465. end;
  466. procedure TIdFTPListItem.SetFileName(const AValue: TIdFTPFileName);
  467. var
  468. i : Integer;
  469. LDoLowerCase : Boolean;
  470. const
  471. LLowCase = 'abcdefghijklmnpqrstuvwxyz'; {do not localize}
  472. begin
  473. if (FLocalFileName = '') or TextIsSame(FFileName, FLocalFileName) then begin
  474. //we do things this way because some file systems use all capital letters or are
  475. //case insensivite. The Unix file is case sensitive and Unix users tend to
  476. //prefer lower case filenames. We do not want to force lowercase if a file
  477. //has both uppercase and lowercase because the uppercase letters are probably intentional
  478. LDoLowerCase := True;
  479. // TODO: add IsLower() functions in IdGlobal/Protocol?
  480. for i := 1 to Length(AValue) do begin
  481. if CharIsInSet(AValue, i, LLowCase) then begin
  482. LDoLowerCase := False;
  483. Break;
  484. end;
  485. end;
  486. if LDoLowerCase then begin
  487. FLocalFileName := LowerCase(AValue);
  488. end else begin
  489. FLocalFileName := AValue;
  490. end;
  491. end;
  492. FFileName := AValue;
  493. end;
  494. end.