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

📄 myfile.cpp

📁 此程式利用ftp與http協定提供多線程下載及斷點續傳功能
💻 CPP
字号:
// MyFile.cpp: 实现CMyFile类.
//
#include "stdafx.h"
#include "MyFile.h"

CMyFile myfile;

//---------------------------------------------------------------------------
CMyFile::CMyFile()
{
}

//---------------------------------------------------------------------------
CMyFile::~CMyFile()
{
}

//---------------------------------------------------------------------------
BOOL CMyFile::FileExists(LPCTSTR lpszFileName)
{
	DWORD dwAttributes = GetFileAttributes(lpszFileName);
    if (dwAttributes == 0xFFFFFFFF)
        return FALSE;

	if ((dwAttributes & FILE_ATTRIBUTE_DIRECTORY) 
		 ==	FILE_ATTRIBUTE_DIRECTORY)
	{
			return FALSE;
	}
	else{
		return TRUE;
	}
}

//---------------------------------------------------------------------------
FILE* CMyFile::GetFilePointer(LPCTSTR lpszFileName)
{
    FILE *fp;
	if(FileExists(lpszFileName)){
		// 打开已有文件进行写数据.
		fp=fopen(lpszFileName,"r+b");
	}
	else{
		// 创建新文件进行写数据.
		fp=fopen(lpszFileName,"w+b");
	}

	return fp;
}

//---------------------------------------------------------------------------
DWORD CMyFile::GetFileSizeByName(LPCTSTR lpszFileName)
{
	if(!FileExists(lpszFileName)) return 0;
	struct _stat ST; 
	// 获取文件长度.
	_stat(lpszFileName, &ST);
	UINT nFilesize=ST.st_size;
	return nFilesize; 
}

//---------------------------------------------------------------------------
// 从全程文件名中提取短文件名.
CString CMyFile::GetShortFileName(LPCSTR lpszFullPathName)
{
   CString strFileName=lpszFullPathName;
   CString strShortName;
   strFileName.TrimLeft();
   strFileName.TrimRight();
   int n=strFileName.ReverseFind('/');
   strShortName=strFileName.Right(strFileName.GetLength()-n-1);
   return strShortName;
}

⌨️ 快捷键说明

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