{ $Project$ $Workfile$ $Revision$ $DateUTC$ $Id$ This file is part of the Indy (Internet Direct) project, and is offered under the dual-licensing agreement described on the Indy website. (http://www.indyproject.org/) Copyright: (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved. } { $Log$ } { Rev 1.11 2/16/2005 7:26:52 AM JPMugaas Should handle Microsoft IIS on Windows XP Professional if the FtpDirBrowseShowLongDate metadata is enabled. That causes digit years to be outputted instead of two digit years. Rev 1.10 10/26/2004 10:03:22 PM JPMugaas Updated refs. Rev 1.9 9/7/2004 10:01:12 AM JPMugaas FIxed problem parsing: drwx------ 1 user group 0 Sep 07 09:20 xxx It was mistakenly being detected as Windows NT because there was a - in the fifth and eigth position in the string. The fix is to detect to see if the other chactors in thbat column are numbers. I did the same thing to the another part of the detection so that something similar doesn't happen there with "-" in Unix listings causing false WindowsNT detection. Rev 1.8 6/5/2004 3:02:10 PM JPMugaas Indicates SizeAvail = False for a directory. That is the standard MS-DOS Format. Rev 1.7 4/20/2004 4:01:14 PM JPMugaas Fix for nasty typecasting error. The wrong create was being called. Rev 1.6 4/19/2004 5:05:16 PM JPMugaas Class rework Kudzu wanted. Rev 1.5 2004.02.03 5:45:16 PM czhower Name changes Rev 1.4 1/22/2004 4:56:12 PM SPerry fixed set problems Rev 1.3 1/22/2004 7:20:54 AM JPMugaas System.Delete changed to IdDelete so the code can work in NET. Rev 1.2 10/19/2003 3:48:16 PM DSiders Added localization comments. Rev 1.1 9/27/2003 10:45:50 PM JPMugaas Added support for an alternative date format. Rev 1.0 2/19/2003 02:01:54 AM JPMugaas Individual parsing objects for the new framework. } unit IdFTPListParseWindowsNT; interface {$i IdCompilerDefines.inc} uses Classes, IdFTPList, IdFTPListParseBase; { Note: This parser comes from the code in Indy 9.0's MS-DOS parser. It has been renamed Windows NT here because that is more accurate than the old name. This is really the standard Microsoft IIS FTP Service format. We have tested this parser with Windows NT 4.0, Windows 2000, and Windows XP. This parser also handles recursive dir lists. } type TIdWindowsNTFTPListItem = class(TIdFTPListItem); TIdFTPLPWindowsNT = class(TIdFTPListBase) protected class function MakeNewItem(AOwner : TIdFTPListItems) : TIdFTPListItem; override; class function ParseLine(const AItem : TIdFTPListItem; const APath : String = ''): Boolean; override; public class function GetIdent : String; override; class function CheckListing(AListing : TStrings; const ASysDescript : String = ''; const ADetails : Boolean = True): Boolean; override; class function ParseListing(AListing : TStrings; ADir : TIdFTPListItems) : Boolean; override; end; const WINNTID = 'Windows NT'; {do not localize} // RLebeau 2/14/09: this forces C++Builder to link to this unit so // RegisterFTPListParser can be called correctly at program startup... {$IFDEF HAS_DIRECTIVE_HPPEMIT_LINKUNIT} {$HPPEMIT LINKUNIT} {$ELSE} {$HPPEMIT '#pragma link "IdFTPListParseWindowsNT"'} {$ENDIF} { Thanks to Craig Peterson of Scooter Software for his verison of TIdFTPLPWindowsNT.CheckListing. } implementation uses IdException, IdGlobal, IdFTPCommon, IdGlobalProtocols, SysUtils; { TIdFTPLPWindowsNT } { IMPORTANT!!! This parser actually handles some variations in the IIS FTP Server. In addition, it also handles some similar formats such as one found in Windows CE and in Rhinosoft's -h:DOS DIR parameter. To do all of this, the detector routine must use string positions because there are some relatively similar but unrelated patterns. Since this is such a highly used parser, it's a good idea to have raw directory lines in comments with the line position 1 so that it could be cut and pasted into a test program. In addition, I use something like " 1 2 3 4 5 1234567890123456789012345678901234567890123456789012345678901234567890 " above a section so that we more easily see the column positions in the string. The header is not part of the actual listing. } class function TIdFTPLPWindowsNT.CheckListing(AListing: TStrings; const ASysDescript: String; const ADetails: Boolean): Boolean; var SDir, sSize : String; i : Integer; SData : String; begin //maybe, we are dealing with this pattern { 1 2 3 4 5 1234567890123456789012345678901234567890123456789012345678901234567890 2002-09-02 18:48