#include "StdAfx.h"
|
#include "MBDownloadFileInfo.h"
|
|
IMPLEMENT_DYNAMIC(CMBDownloadFileInfo, CMBBaseObj)
|
|
CMBDownloadFileInfo::CMBDownloadFileInfo(void)
|
{
|
m_nStatus = Status_None; // ״̬
|
m_nFileSize = 0; // Îļþ´óС
|
m_nIsDir = 0; // 1ÊÇĿ¼£¬0 ²»ÊÇ
|
m_nTrID = 0;
|
m_nTransRate = 0; // ´«ÊäËÙÂÊ
|
m_nOldTickCount = 0;
|
m_nOldTranferedSize = 0;
|
m_nCabinetType = 0;
|
}
|
|
|
CMBDownloadFileInfo::~CMBDownloadFileInfo(void)
|
{
|
}
|
|
void CMBDownloadFileInfo::SetStatus( int nStatus )
|
{
|
CSingleLock lock( &m_cs, true );
|
|
if( m_nStatus == Status_Delete || m_nStatus == Status_DeleteOnQueue )
|
return ;
|
m_nStatus = nStatus;
|
}
|
|
int CMBDownloadFileInfo::GetStatus()
|
{
|
CSingleLock lock( &m_cs, true );
|
return m_nStatus;
|
}
|
|
//void CMBDownloadFileInfo::SetMD5(CString strMD5)
|
//{
|
// CSingleLock lock( &m_cs, true );
|
//
|
// m_strMD5 = strMD5;
|
//}
|
//
|
//CString CMBDownloadFileInfo::GetMD5()
|
//{
|
// CSingleLock lock( &m_cs, true );
|
// return m_strMD5;
|
//}
|
|
void CMBDownloadFileInfo::SetErr(CString strErr)
|
{
|
CSingleLock lock( &m_cs, true );
|
m_strErr = strErr;
|
}
|
|
CString CMBDownloadFileInfo::GetErr()
|
{
|
CSingleLock lock( &m_cs, true );
|
return m_strErr;
|
}
|
|
|
|
void CMBDownloadFileInfo::SetTrID( int nTrID )
|
{
|
CSingleLock lock( &m_cs, true );
|
m_nTrID = nTrID;
|
}
|
|
int CMBDownloadFileInfo::GetTrID()
|
{
|
CSingleLock lock( &m_cs, true );
|
|
return m_nTrID;
|
}
|
|
void CMBDownloadFileInfo::SetLocalPath(CString strLocalPath)
|
{
|
CSingleLock lock( &m_cs, true );
|
m_strLocalPath = strLocalPath;
|
}
|
|
CString CMBDownloadFileInfo::GetLocalPath()
|
{
|
CSingleLock lock( &m_cs, true );
|
return m_strLocalPath;
|
}
|
|
|
CString CMBDownloadFileInfo::GetFileType()
|
{
|
CSingleLock lock( &m_cs, true );
|
return CStrFileUtils::GetFileExtName(m_strLocalPath);
|
}
|
|
CString CMBDownloadFileInfo::GetFileName()
|
{
|
CSingleLock lock( &m_cs, true );
|
return CStrFileUtils::GetFileName(m_strLocalPath);
|
}
|
|
CString CMBDownloadFileInfo::GetFullFileName()
|
{
|
CSingleLock lock( &m_cs, true );
|
return m_strLocalPath;
|
}
|
|
CString CMBDownloadFileInfo::GetDownloadFileName()
|
{
|
CSingleLock lock( &m_cs, true );
|
|
CString strName;
|
CString strPath;
|
CString strFileName;
|
CString strFileType;
|
|
strFileType = GetFileType();
|
strPath = CStrFileUtils::GetPath(m_strLocalPath);
|
if(!CStrFileUtils::IsDirExit(strPath))
|
{
|
CStrFileUtils::CreateDir( strPath );
|
}
|
|
//// Èç¹ûÀ´Ô´ÊDZà¼
|
//if( m_strFrom == FCTN_ED )
|
//{
|
// m_strLocalPath.Format(_T("%s\%s%s"),strPath,m_strFileID,strFileType);
|
// return m_strLocalPath;
|
//}
|
|
|
if( !CStrFileUtils::IsExist(m_strLocalPath) )
|
{
|
return m_strLocalPath;
|
}
|
|
int nPos = CStrFileUtils::GetFileName(m_strLocalPath).Find(_T("."));
|
strName = CStrFileUtils::GetFileName(m_strLocalPath).Mid(0,nPos);
|
|
int nIndex = 1;
|
while( true )
|
{
|
strFileName.Format(_T("%s\\%s(%d)%s"),strPath,strName,nIndex,strFileType);
|
if( !CStrFileUtils::IsExist(strFileName) )
|
{
|
return strFileName;
|
}
|
nIndex++;
|
}
|
return strFileName;
|
}
|