MyFtpList.cpp
资源名称:FTP总集.rar [点击查看]
上传用户:tjfeida
上传日期:2013-03-10
资源大小:1917k
文件大小:1k
源码类别:
Ftp客户端
开发平台:
Visual C++
- #include "StdAfx.h"
- #include ".myftplist.h"
- #include "MyFtpList.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- MyFtpList::MyFtpList(void)
- : m_bDirectory(FALSE)
- , m_strsst(_T(""))
- , m_strDate(_T(""))
- , m_strName(_T(""))
- , m_index(0)
- {
- }
- MyFtpList::~MyFtpList(void)
- {
- }
- //获取文件或者文家夹头标信息
- int MyFtpList::GetImage(void)
- {
- if(m_bDirectory)
- return 7;
- else
- return 3;
- }
- //解析文件信息;
- BOOL MyFtpList::ParseLine(CString strLine)
- {
- if(strLine.IsEmpty())
- return FALSE;
- char ch=strLine.GetAt(0);
- if(ch=='d'||ch=='D')
- {
- m_bDirectory=TRUE;
- }
- else
- if(ch=='-')
- m_bDirectory=FALSE;
- else
- {
- if(strLine.Find("<DIR>")!=-1||strLine.Find("<dir>")!=-1)
- m_bDirectory=TRUE;
- else
- m_bDirectory=FALSE;
- if(strLine.GetLength()<40)
- return FALSE;
- m_strName=strLine.Mid(39);
- m_strDate=strLine.Left(18);
- m_strName.TrimLeft();
- m_strName.TrimRight();
- return TRUE;
- }
- m_bsst=0;
- //获取时间表示方法
- for(int i=0;i<9;i++)
- {
- ch=strLine.GetAt(i);
- if(ch=='-')
- m_bsst|=0x01;
- m_bsst<< 1;
- }
- m_strsst = strLine.Mid(1, 9);
- int index = strLine.Find(':');
- if(index == -1)
- {
- if(strLine.GetLength() > 56)
- index = 51;
- else
- return FALSE;
- }
- m_index = index;
- m_strName = strLine.Mid(index + 3);
- m_strName.TrimLeft();
- m_strName.TrimRight();
- m_strDate = strLine.Mid(index - 9, 12);
- return TRUE;
- }