资源简介

基于MFC实现的FTP可断点续传的客户端,实现了断点上传和断点下载的功能,可以运行,无论是学习还是拿到项目中使用都很有用。

资源截图

代码片段和文件信息

#include “stdafx.h“
#include “FileLogger.h“
#include 

#include 
using std::string;

static FileLogger *instance = NULL;

CRITICAL_SECTION allocCriticalSection;

class FileLogger::Private
{
public:
Private(FileLogger *parent = 0);
~Private();

/* Data members */
CFile logFile;
string logFileName;
string logFileCopy;

private:
FileLogger *q;
};


FileLogger::Private::Private(FileLogger *parent): q(parent)
{
InitializeCriticalSection(&allocCriticalSection);
}

FileLogger::Private::~Private()
{
DeleteCriticalSection(&allocCriticalSection);
}

FileLogger::FileLogger(void)
{
d = new Private(this);
d->logFileName = “/Storage/HandHeld/log.txt“;
d->logFileCopy = “/Storage/HandHeld/logCopy.txt“;

instance = this;
Open();
}

FileLogger::~FileLogger(void)
{
Close();
delete d;
}

void FileLogger::Debug(string what)
{
what += “\r\n“;

string temp;
char buffer[15];
CTime currentTime = CTime::GetCurrentTime();
sprintf(buffer  “%d:%d:%d  “  currentTime.GetHour()  currentTime.GetMinute()  currentTime.GetSecond());
temp += string(buffer);

temp += what;
d->logFile.Write(temp.c_str()  temp.length());
}

FileLogger* FileLogger::GetInstance()
{
EnterCriticalSection(&allocCriticalSection);
if(instance == NULL)
instance = new FileLogger();
LeaveCriticalSection(&allocCriticalSection);
return instance;
}

void FileLogger::Open(FileLogger::OpenMode mode)
{
if(mode == Truncate)
d->logFile.Open(CString(d->logFileName.c_str())  CFile::modeCreate | CFile::modeWrite);
else
{
d->logFile.Open(CString(d->logFileName.c_str())  CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite);
d->logFile.SeekToEnd();
}
}

void FileLogger::Close()
{
Flush();
d->logFile.Close();
}

void FileLogger::Flush()
{
d->logFile.Flush();
}

void FileLogger::WriteErrorTag()
{
string error(“\r\n\r\n ----------> Log - Error“);
d->logFile.Write(error.c_str()  error.length());
Close();

CopyFile(CString(d->logFileName.c_str())  CString(d->logFileCopy.c_str())  FALSE);
Open(Append);
d->logFile.Write(“\r\n\r\n ----------> Log - Restart“  strlen(“\r\n\r\n ----------> Log - Restart“));
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-12-31 14:36  FtpClient\
     目录           0  2014-01-03 09:49  FtpClient\.svn\
     文件           3  2013-09-25 11:02  FtpClient\.svn\entries
     文件           3  2013-09-25 11:02  FtpClient\.svn\format
     目录           0  2014-01-03 09:49  FtpClient\.svn\pristine\
     目录           0  2013-12-31 14:38  FtpClient\.svn\pristine\02\
     文件         264  2013-12-31 14:38  FtpClient\.svn\pristine\02\02e5c5bb18e3347d89a48b69024abb81c073d441.svn-base
     目录           0  2013-09-25 11:02  FtpClient\.svn\pristine\06\
     文件        1474  2013-09-25 11:02  FtpClient\.svn\pristine\06\067d69c7831a8005b417203147fa0875fd83a987.svn-base
     目录           0  2013-09-25 11:08  FtpClient\.svn\pristine\0a\
     文件       24304  2013-09-25 11:08  FtpClient\.svn\pristine\0a\0a91ff1013fd346f14fc4714a0d81ee1daab3e6f.svn-base
     目录           0  2014-01-03 09:49  FtpClient\.svn\pristine\15\
     文件         923  2014-01-03 09:49  FtpClient\.svn\pristine\15\151a2d354fcba2a33af44848ba3fb83d159bbb80.svn-base
     目录           0  2013-12-31 14:38  FtpClient\.svn\pristine\17\
     文件         483  2013-12-31 14:38  FtpClient\.svn\pristine\17\17f3af07ef2398ed01cb25f405f921805784dc00.svn-base
     目录           0  2013-09-25 11:02  FtpClient\.svn\pristine\1c\
     文件         886  2013-09-25 11:02  FtpClient\.svn\pristine\1c\1c5126675111f027f2da0b17cf56f6fab7a510bf.svn-base
     目录           0  2013-12-31 14:38  FtpClient\.svn\pristine\1d\
     文件        1090  2013-12-31 14:38  FtpClient\.svn\pristine\1d\1d9f864a7a9a078c14c88f29fcf471f91dce4c1b.svn-base
     目录           0  2014-01-03 09:49  FtpClient\.svn\pristine\22\
     文件        7608  2014-01-03 09:49  FtpClient\.svn\pristine\22\22beb8d8988af31518ea744b21c76a16e076850b.svn-base
     目录           0  2013-09-25 11:08  FtpClient\.svn\pristine\33\
     文件        3471  2013-09-25 11:08  FtpClient\.svn\pristine\33\33718b3ff5050d5d4d3833174725f7c8b6b4c96e.svn-base
     目录           0  2013-09-25 11:02  FtpClient\.svn\pristine\36\
     文件          92  2013-09-25 11:02  FtpClient\.svn\pristine\36\365ea9ea29cb184894117c7e698b42fba1e4c6fb.svn-base
     目录           0  2013-12-31 14:37  FtpClient\.svn\pristine\37\
     文件        1363  2013-12-31 14:37  FtpClient\.svn\pristine\37\376aabcd2790fd0c2ee0eae4101355ccd23b1ccf.svn-base
     目录           0  2013-12-31 14:37  FtpClient\.svn\pristine\3b\
     文件        7776  2013-12-31 14:37  FtpClient\.svn\pristine\3b\3bcbac96482755bbfe799f74a9f254f4f0a3d98c.svn-base
     目录           0  2013-09-25 11:02  FtpClient\.svn\pristine\3f\
     文件        1343  2013-09-25 11:02  FtpClient\.svn\pristine\3f\3f64195bf9fad17ad8505a5af171f9d94c6d2d0a.svn-base
............此处省略57个文件信息

评论

共有 条评论