#include<iosteam>#include<iostream>
#include<string>
using namespace std;
#define uchar unsigned char
uchar buf[1<<20];
void filecopy(string f1,string f2){
FILE *ifp=fopen(f1.c_str(),"rb");
FILE *ofp=fopen(f2.c_str(),"wb");
// system("cls");
getchar();
// uchar *p1=buf,*p2=buf;
// size_t tot=0;
while(1){
size_t cnt=fread(buf,1,1<<20,ifp);
if(cnt==0)break;
fwrite(buf,1,cnt,ofp);
// tot+=cnt;
// string s=to_string(tot)+" byte(s) data has been copied.";
// setCursorPos(0,0);
// cout<<s<<"\n";
}
cout<<"Completed.\n";
getchar();
fclose(ifp);
fclose(ofp);
} #include<iostream>
#include<string>
#include<vector>
using namespace std;
#define uchar unsigned char
uchar buf[1<<20];
void copyfile(string f1,string f2){
FILE *ifp=fopen(f1.c_str(),"rb");
FILE *ofp=fopen(f2.c_str(),"wb");
if(ifp==nullptr||ofp==nullptr)return ;
// system("cls");
// uchar *p1=buf,*p2=buf;
// size_t tot=0;
while(1){
size_t cnt=fread(buf,1,1<<20,ifp);
if(cnt==0)break;
fwrite(buf,1,cnt,ofp);
// tot+=cnt;
// string s=to_string(tot)+" byte(s) data has been copied.";
// setCursorPos(0,0);
// cout<<s<<"\n";
}
// cout<<"Completed.\n";
cout<<"[copyfile] "<<f1<<" "<<f2<<" \n";
fclose(ifp);
fclose(ofp);
}
string gtl(){
string res="";
char ch;
while((ch=getchar())&&ch!=EOF){
if(ch=='\r')continue;
if(ch=='\n')break;
res+=ch;
}
return res;
}
void mkdir(string name){
cout<<"[mkdir] "<<name<<"\n";
string comm="mkdir \""+name+"\" > nul 2>nul";
system(comm.c_str());
}
string hsh(string s){
string x16="0123456789abcdef";
string res="";
for(int i=0;i<s.size();i++){
res+=x16[(s[i]>>4)];
res+=x16[(s[i]&15)];
}
return res;
}
void explorer(string path1,string path2){
mkdir(path2);
vector<string>dir;
system(((string)"dir \""+path1+"\" /A-D /B > tmp 2>nul").c_str());
freopen("tmp","r",stdin);
string fn;
while(1){
fn=gtl();
if(fn=="")break;
copyfile(path1+"\\"+fn,path2+"\\"+fn);
}
system(((string)"dir \""+path1+"\" /AD /B > tmp 2>nul").c_str());
freopen("tmp","r",stdin);
while(1){
fn=gtl();
if(fn=="")break;
dir.push_back(fn);
}
for(auto fn:dir){
explorer(path1+"\\"+fn,path2+"\\"+fn);
}
}
int main(){
freopen("copy.log","w",stdout);
string path1,path2;
path1=gtl(),path2=gtl();
explorer(path1,path2);
}2025.12.16 红名祭
2026.4.16 在课后延时使用 min 从 数到 (?