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

📄 bet2.cpp

📁 DEMO程序
💻 CPP
字号:
// bet2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "windows.h"
#include "io.h"
#include "stdio.h"

void scanAllFiles( char *filePath )
{
	struct _finddata_t fileInfo;
	int done;
	char filePathCpy[MAX_PATH];
	
	strcpy( filePathCpy, filePath );
	done = _findfirst( filePath, &fileInfo );
	if( done == -1 )  //打开路径失败返回 
	{
		return;
	}
    
	int tag=0;
    while( tag != -1 ) //从第一个文件..第N个文件 
	{
		if( !strcmp( fileInfo.name, "." ) || !strcmp( fileInfo.name, ".." ) )
		{
			tag=_findnext( done, &fileInfo ); //查找下一个配匹的文件
			continue;
		}
		
		//取得全路径 
        char fullPath[ MAX_PATH ];
		strcpy( fullPath, filePathCpy );
		fullPath[ strlen( fullPath ) - strlen( "*" ) ] = '\0';//去掉\\*
		strcat( fullPath, fileInfo.name );
        
		if ( fileInfo.attrib & _A_SUBDIR ) //是一个文件夹 
		{
			strcat( fullPath, "\\*" );
			//printf("\n");
			//printf("--%s--\n", fullPath );
            scanAllFiles( fullPath ); //递归扫描该文件夹的子文件
		}
		else
		{
			printf("%s\n", fullPath);
			//printf("%s\n", fileInfo.name );
		}
		tag=_findnext(done,&fileInfo); //查找下一个配匹的文件
	}
	_findclose(done);
}

#define MAX_FILE_BUF_LENGTH 1024
bool compareFile(char * pScrFileName, char * pTagFileName)
{
	bool res = TRUE;
	FILE * in1 = NULL;
	FILE * in2 = NULL;
	long len1 = 0;
	long len2 = 0;
	char buf1[MAX_FILE_BUF_LENGTH];
	char buf2[MAX_FILE_BUF_LENGTH];
	memset(buf1, 0, MAX_FILE_BUF_LENGTH);
	memset(buf2, 0, MAX_FILE_BUF_LENGTH);
		
	in1 = fopen(pScrFileName, "rb");
	in2 = fopen(pTagFileName, "rb");
	
	len1 = fread(buf1,1,MAX_FILE_BUF_LENGTH,in1);
	len2 = fread(buf2,1,MAX_FILE_BUF_LENGTH,in2);

	while(len1 != 0)
	{
		if (len1 != len2)
		{
			res = FALSE;
			break;
		}
		
		if (memcmp(buf1, buf2, len1))
		{
			res = FALSE;
			break;
		}
		
		len1 = fread(buf1,1,MAX_FILE_BUF_LENGTH,in1);
		len2 = fread(buf2,1,MAX_FILE_BUF_LENGTH,in2);
	}
	
	return res;
}

int main(int argc, char* argv[])
{
	scanAllFiles("D:\\cp\\ver3429\\*");
/*
	bool res = compareFile("D:\\cp\\ver3429\\SK\\Install\\dotnetfx.exe",
							"D:\\cp\\version3.4.39_20070226\\SK\\Install\\dotnetfx.exe");
	if (res)
	{
		printf("Match!\n");
	}
	else
	{
		printf("MISS!\n");
	}
*/
	return 0;
}

⌨️ 快捷键说明

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