ftplistresult.cpp
来自「一个FTP下载的源代码。代码质量非常高」· C++ 代码 · 共 207 行
CPP
207 行
// FileZilla - a Windows ftp client
// Copyright (C) 2002 - Tim Kosse <tim.kosse@gmx.de>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// FtpListResult.cpp: Implementierung der Klasse CFtpListResult.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "FtpListResult.h"
#include "FileZillaApi.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Konstruktion/Destruktion
//////////////////////////////////////////////////////////////////////
//#define LISTDEBUG
#ifdef LISTDEBUG
//It's the normal UNIX format (or even another nonstandard format)
//Some samples are from http://cr.yp.to/ftpparse/ftpparse.c
/* UNIX-style listing, without inum and without blocks */
static char data[][100]={
"-rw-r--r-- 1 root other 531 Jan 29 03:26 README",
"dr-xr-xr-x 2 root other 512 Apr 8 1994 etc",
"dr-xr-xr-x 2 root 512 Apr 8 1994 etc2",
"lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin",
/* Some listings with uncommon date/time format: */
"-rw-r--r-- 1 root other 531 09-26 2000 README2",
"-rw-r--r-- 1 root other 531 09-26 13:45 README3",
"-rw-r--r-- 1 root other 531 2005-06-07 21:22 README4",
/* Also produced by Microsoft's FTP servers for Windows: */
"---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z",
"d--------- 1 owner group 0 May 9 19:45 Softlib",
/* Also WFTPD for MSDOS: */
"-rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp",
/* Also NetWare: */
"d [R----F--] supervisor 512 Jan 16 18:53 login",
"- [R----F--] rhesus 214059 Oct 20 15:27 cx.exe",
/* Also NetPresenz for the Mac: */
"-------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit",
"drwxrwxr-x folder 2 May 10 1996 network",
/* Some other formats some windows servers send */
"-rw-r--r-- 1 root 531 Jan 29 03:26 README5",
"-rw-r--r-- 1 group domain user 531 Jan 29 03:26 README6",
/* EPLF directory listings */
"+i8388621.48594,m825718503,r,s280,\teplf test 1.file",
"+i8388621.50690,m824255907,/,\teplf test 2.dir",
"+i8388621.48598,m824253270,r,s612,\teplf test 3.file",
/* MSDOS type listing used by IIS */
"04-27-00 09:09PM <DIR> DOS dir 1",
"04-14-00 03:47PM 589 DOS file 1",
/* Another type of MSDOS style listings */
"2002-09-02 18:48 <DIR> DOS dir 2",
"2002-09-02 19:06 9,730 DOS file 2",
/* Numerical Unix style format */
"0100644 500 101 12345 123456789 filename",
/* This one is used by SSH-2.0-VShell_2_1_2_143, this is the old VShell format */
"206876 Apr 04, 2000 21:06 VShell (old)",
"0 Dec 12, 2002 02:13 VShell (old) Dir/",
/* This type of directory listings is sent by some newer versions of VShell
* both year and time in one line is uncommon.
*/
"-rwxr-xr-x 1 user group 9 Oct 08, 2002 09:47 VShell (new)",
/* Next ones come from an OS/2 server. The server obviously isn't Y2K aware */
"36611 A 04-23-103 10:57 OS2 test1.file",
" 1123 A 07-14-99 12:37 OS2 test2.file",
" 0 DIR 02-11-103 16:15 OS2 test1.dir",
" 1123 DIR A 10-05-100 23:38 OS2 test2.dir",
/* Some servers send localized date formats, here the German one: */
"dr-xr-xr-x 2 root other 2235 26. Juli, 20:10 datetest1 (ger)",
"-r-xr-xr-x 2 root other 2235 2. Okt. 2003 datetest2 (ger)",
"-r-xr-xr-x 2 root other 2235 1999/10/12 17:12 datetest3",
"-r-xr-xr-x 2 root other 2235 24-04-2003 17:12 datetest4",
/* Here a Japanese one: */
"-rw-r--r-- 1 root sys 8473 4\x8c\x8e 18\x93\xfa 2003\x94\x4e datatest1 (jap)",
/* VMS style listings */
"vms_dir_1.DIR;1 1 19-NOV-2001 21:41 [root,root] (RWE,RWE,RE,RE)",
/* VMS multiline */
"VMS_file_1;1\r\n170774/170775 24-APR-2003 08:16:15 [FTP_CLIENT,SCOT] (RWED,RWED,RE,)",
"VMS_file_2;1\r\n10 2-JUL-2003 10:30:08.59 [FTP_CLIENT,SCOT] (RWED,RWED,RE,)",
/* IBM AS/400 style listing */
"QSYS 77824 02/23/00 15:09:55 *DIR IBM Dir1/",
/* aligned directory listing with too long size */
"-r-xr-xr-x longowner longgroup123456 Feb 12 17:20 long size test1",
/* short directory listing with month name */
"-r-xr-xr-x 2 owner group 4512 01-jun-99 shortdate with monthname",
""};
#endif
CFtpListResult::CFtpListResult(t_server server)
{
listhead=curpos=0;
m_server = server;
pos=0;
m_prevline=0;
m_curline=0;
m_curlistaddpos=0;
//Fill the month names map
//English month names
m_MonthNamesMap[_T("jan")] = 1;
m_MonthNamesMap[_T("feb")] = 2;
m_MonthNamesMap[_T("mar")] = 3;
m_MonthNamesMap[_T("apr")] = 4;
m_MonthNamesMap[_T("may")] = 5;
m_MonthNamesMap[_T("jun")] = 6;
m_MonthNamesMap[_T("june")] = 6;
m_MonthNamesMap[_T("jul")] = 7;
m_MonthNamesMap[_T("july")] = 7;
m_MonthNamesMap[_T("aug")] = 8;
m_MonthNamesMap[_T("sep")] = 9;
m_MonthNamesMap[_T("sept")] = 9;
m_MonthNamesMap[_T("oct")] = 10;
m_MonthNamesMap[_T("nov")] = 11;
m_MonthNamesMap[_T("dec")] = 12;
//Numerical values for the month
m_MonthNamesMap[_T("1")] = 1;
m_MonthNamesMap[_T("01")] = 1;
m_MonthNamesMap[_T("2")] = 2;
m_MonthNamesMap[_T("02")] = 2;
m_MonthNamesMap[_T("3")] = 3;
m_MonthNamesMap[_T("03")] = 3;
m_MonthNamesMap[_T("4")] = 4;
m_MonthNamesMap[_T("04")] = 4;
m_MonthNamesMap[_T("5")] = 5;
m_MonthNamesMap[_T("05")] = 5;
m_MonthNamesMap[_T("6")] = 6;
m_MonthNamesMap[_T("06")] = 6;
m_MonthNamesMap[_T("7")] = 7;
m_MonthNamesMap[_T("07")] = 7;
m_MonthNamesMap[_T("8")] = 8;
m_MonthNamesMap[_T("08")] = 8;
m_MonthNamesMap[_T("9")] = 9;
m_MonthNamesMap[_T("09")] = 9;
m_MonthNamesMap[_T("10")] = 10;
m_MonthNamesMap[_T("11")] = 11;
m_MonthNamesMap[_T("12")] = 12;
//German month names
m_MonthNamesMap[_T("mrz")] = 3;
m_MonthNamesMap[_T("m鋜")] = 3;
m_MonthNamesMap[_T("m鋜z")] = 3;
m_MonthNamesMap[_T("mai")] = 5;
m_MonthNamesMap[_T("juni")] = 5;
m_MonthNamesMap[_T("juli")] = 6;
m_MonthNamesMap[_T("okt")] = 10;
m_MonthNamesMap[_T("dez")] = 12;
//French month names
m_MonthNamesMap[_T("janv")] = 1;
m_MonthNamesMap[_T("f閎")] = 1;
m_MonthNamesMap[_T("f関")] = 2;
m_MonthNamesMap[_T("fev")] = 2;
m_MonthNamesMap[_T("f関r")] = 2;
m_MonthNamesMap[_T("fevr")] = 2;
m_MonthNamesMap[_T("mars")] = 3;
m_MonthNamesMap[_T("avr")] = 4;
m_MonthNamesMap[_T("juin")] = 7;
m_MonthNamesMap[_T("juil")] = 7;
m_MonthNamesMap[_T("ao
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?