⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftphelp.cpp

📁 自己改写的在WINCE上开发用的EVC++的FTP操作示例工程,希望能给相关人士提供帮助.
💻 CPP
字号:

#include "stdafx.h"
#include "FTPHelp.h"

using namespace nsHelper;
using namespace nsFTP;

CMakeString& CMakeString::operator<<(DWORD dwNum)
{
	m_str.Format("%s%u",m_str.GetString(), dwNum);

	return *this;
}

CMakeString& CMakeString::operator<<(const CStringA& strAdd)
{
	m_str += strAdd;
	return *this;
}

CMakeString& CMakeString::operator<<(const LPSTR strAdd)
{
	m_str += strAdd;
	return *this;
}

CFileT::CFileT() : m_pFile(NULL) 
{
}

CFileT::~CFileT()
{
	Close();
}

bool CFileT::Open(CStringA strFileName, CStringA strMode)
{
	m_pFile = fopen(strFileName.GetString(),strMode.GetString());
	return m_pFile!=NULL;
}

bool CFileT::Close()
{
	FILE* pFile = m_pFile;
	m_pFile = NULL;
	return pFile && fclose(pFile)==0;
}

bool CFileT::Seek(long lOffset, T_enOrigin enOrigin)
{
	return m_pFile && fseek(m_pFile, lOffset, enOrigin)==0;
}

long CFileT::Tell()
{
	if( !m_pFile )
		return -1L;
	return ftell(m_pFile);
}

size_t CFileT::Write(const void* pBuffer, size_t itemSize, size_t itemCount)
{
	if( !m_pFile )
		return 0;
	return fwrite(pBuffer, itemSize, itemCount, m_pFile);
}

size_t CFileT::Read(void* pBuffer, size_t itemSize, size_t itemCount)
{
	if( !m_pFile )
		return 0;
	return fread(pBuffer, itemSize, itemCount, m_pFile);
}

void CFileT::OnBytesReceived(CDataStack2& vBuffer, long lReceivedBytes)
{
	Write(vBuffer.GetData(), sizeof(char), lReceivedBytes);
}

void CFileT::OnPreBytesSend(CDataStack2& vBuffer, size_t& bytesToSend)
{
	bytesToSend = Read(vBuffer.GetData(), sizeof(char), vBuffer.Length());
}

void COutputStream::SetStartPosition()
{
	m_itCurrentPos = 0;
}

COutputStream::COutputStream(const CStringA& strEolCharacterSequence):
mc_strEolCharacterSequence(strEolCharacterSequence)
{
	m_itCurrentPos = m_vBuffer.Length();
}

bool COutputStream::GetNextLine(CStringA& strLine)// const
{
	int nFlag = -1;
	strLine = m_vBuffer.ReadLine(nFlag,(LPSTR)(LPCSTR)mc_strEolCharacterSequence);
	
	return (nFlag == 1);
}

void COutputStream::OnBytesReceived(CDataStack2& vBuffer, long lReceivedBytes)
{
	m_vBuffer.Append(vBuffer.GetData(),lReceivedBytes);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -