【VC开源代码栏目提醒】:以下是网学会员为您推荐的VC开源代码-FtpFileFind.cpp,希望本篇文章对您学习有所帮助。
// FtpFileFind.cpp: implementation of the CFtpFileFind class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ftpclient.h"
#include "FtpFileFind.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFtpFileFind::CFtpFileFind()
{
AddTail("..");
m_pFile = NULL;
}
CFtpFileFind::~CFtpFileFind()
{
}
void CFtpFileFind::RemoveAll()
{
m_lstFile.RemoveAll();
AddTail("..");
}
void CFtpFileFind::AddTail(LPCTSTR lpszName, BOOL bIsDirectory)
{
CFtpFile file(lpszName,bIsDirectory);
m_lstFile.AddTail(file);
}
POSITION CFtpFileFind::GetFirstFile()
{
return m_lstFile.GetHeadPosition();
}
BOOL CFtpFileFind::GetNextFile(POSITION &pos)
{
if (pos == NULL)
return FALSE;
m_pFile = &(m_lstFile.GetNext(pos));
return m_pFile != NULL;
}
BOOL CFtpFileFind::FindFile(LPCTSTR lpszName)
{
CString strName;
POSITION pos = GetFirstFile();
while (GetNextFile(pos))
{
strName = m_pFile->GetName();
if (!strName.Compare(lpszName))
return TRUE;
}
return FALSE;
}
BOOL CFtpFileFind::IsDirectory()
{
ASSERT(m_pFile);
return m_pFile->IsDirectory();
}
LPCTSTR CFtpFileFind::GetFileName()
{
return m_pFile->GetName();
}