diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c578039 Binary files /dev/null and b/.DS_Store differ diff --git a/change.h b/change.h new file mode 100644 index 0000000..63bea11 --- /dev/null +++ b/change.h @@ -0,0 +1,71 @@ +// Copyright (C) 2018 AdemJensen +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 3, +// or (at your option) any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +void changesettings() +{ + while(true) + { + clearall(); + string cbef="[?ȴ??Ӧ]?ѡ?????ĵ??\n________________________________________\n"; + string sel1="????:"+exename; + string sel2="?????ʼ??:"+itos(from); + string sel3="????????:"+itos(to); + string sel4="?????:"+inname; + string sel5="??????:"+outname; + int select=arrowselect(cbef,"________________________________________",6,1,sel1.c_str(),2,sel2.c_str(),2,sel3.c_str(),2,sel4.c_str(),3,sel5.c_str(),4,"[??????"); + announcedata(); + if(select==1) + { + bool curok=false; + string temp; + while(!curok) curok=loadexename(temp); + } + if(select==2) + { + bool curok=false; + string temp; + while(true) + { + while(true) + { + curok=false; + while(!curok) curok=loadfrom(temp); + curok=false; + while(!curok) curok=loadto(temp); + if(from>to) + { + _err("[?????ʼ????ڽ????!\n"); + toset=false; + fromset=false; + continue; + } + break; + } + curok=false; + while(!curok) curok=loadinname(temp); + if(!infilecheck(inname,from,to,true)) continue; + break; + } + } + if(select==3) + { + bool curok=false; + string temp; + while(!curok||!checkallset(true)) curok=loadoutname(temp); + } + if(select==4) return; + } +} diff --git a/checksys.h b/checksys.h new file mode 100644 index 0000000..cf712bf --- /dev/null +++ b/checksys.h @@ -0,0 +1,202 @@ +// Copyright (C) 2018 AdemJensen +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 3, +// or (at your option) any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +bool checkexename(string s,bool show) +{ + if(show) cout<<"[Ϣ]ڼexeϷ..."; + int len=s.size(); + if(s[len-4]!='.'||s[len-3]!='e'||s[len-2]!='x'||s[len-1]!='e') + { + cline(); + if(show) _err("[]ָļexeļ!\n"); + return false; + } + if(!exist(s)) + { + cline(); + if(show) _err("[]޷ҵָexeļ!\n"); + return false; + } + if(s==currentexe) + { + cline(); + if(show) _err("[]ָתΪĿexe!\n"); + return false; + } + string opera=s+" -anti-reopen-mode"; + cline();_warn("[ע]exeҪexeб\n"); + + WinExec(opera.c_str(),SW_SHOW); + + Sleep(500); + opera="taskkill /IM "+s; + opera+=" /f"; + system(opera.c_str()); + clearall(); + + if(!exist("std.out")) + { + cline(); + if(show) _err("[]ָexeδȷļ!\n"); + return false; + } + remove("std.out"); + //remove("std.in"); + cline(); + return true; +} + +bool checkrule(string s,bool show) +{ + int len=s.size(); + int pos; + bool ok=true; + bool havenes=false; + for(int i=0;i. + +bool mainconversion(bool show) +{ + if(show) clearall(); + string outfilename; + string infilename; + announcedata(); + for(int i=from;i<=to;i++) + { + infilename=getfilename(inname,i); + outfilename=getfilename(outname,i); + if(show) cout<<"[Ϣ]ת: "< "< "),_err(outfilename),_err(":\n"); + if(show) _err("[]ṩijʱ!ֵ:"),_err(result),_err('\n'); + if(show) _err("[]ȡ!\n"); + remove("std.in");remove("std.out"); + return false; + } + CopyFile("std.out",outfilename.c_str(),false); + remove("std.in");remove("std.out"); + if(show) cline(); + } + if(show) cline(); + return true; +} diff --git a/load.h b/load.h new file mode 100644 index 0000000..978e6bf --- /dev/null +++ b/load.h @@ -0,0 +1,265 @@ +// Copyright (C) 2018 AdemJensen +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 3, +// or (at your option) any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +bool Manual_load(bool show) +{ + if(show) clearall(); + if(show) cout<<"[Ϣ]ڽֶ:"<to) + { + if(show) _err("[]ʼŴڽ!\n"); + toset=false; + fromset=false; + continue; + } + break; + } + curok=false; + while(!curok) curok=loadinname(temp); + if(!infilecheck(inname,from,to,true)) continue; + break; + } + curok=false; + while(!curok||!checkallset(true)) curok=loadoutname(temp); + if(show) _ok("[Ϣ]ȫ!\n"); + if(show) cout<<"[ȴӦ]"<to) + { + if(show) _err("[]ʼŴڽ!\n"); + ok=false; + } + if(!infilecheck(inname,from,to,show)) ok=false; + if(checkallset(show)&&ok) + { + if(show) _ok("[Ϣ]ȫȡ!\n"); + if(show) cout<<"[ȴӦ]"< __filelist.txt"); + fstream list; + if(!openstream(list,"__filelist.txt","in")) + { + if(show) _err("[]޷ļ!\n"); + system("del __filelist.txt"); + if(show) pause(); + return false; + } + int exenum=0; + string curline; + while(getline(list,curline)) + { + if((int)curline.find(".exe")!=-1) + { + exenum++; + } + } + list.close(); + if(exenum>=4) + { + if(show) _warn("[]ļ"),_warn(exenum),_warn("exeļϵͳΧ\n"); + if(show) _warn("[]ڰȫǣԶѱܾ\n"); + if(show) _err("[]Զʧ!볢ģʽ!\n"); + system("del __filelist.txt"); + if(show) pause(); + return false; + } + int leastinserial=9999; + openstream(list,"__filelist.txt","in"); + while(getline(list,curline)) + { + if((int)curline.find(".exe")!=-1) + { + if(checkexename(curline,false)&&!exenameset) + { + exename=curline; + exenameset=true; + if(show) _ok("[Ϣ]ҵexeļ:"),_ok(exename),_ok('\n'); + } + } + else + { + int len=curline.size(); + int dpos=0; + string anawhy; + for(int i=0;i. + + +bool loadexename(string &temp) +{ + cout<<":"; + getline(cin,temp); + temp=nfaspace(temp); + if(checkexename(temp,true)) + { + exenameset=true; + exename=temp; + return true; + } + return false; +} +bool loadfrom(string &temp) +{ + fromset=false; + from=9999; + cout<<"ļʼ:"; + getline(cin,temp); + temp=nfaspace(temp); + if(checknum(temp,true)) + { + fromset=true; + from=stoi(temp); + return true; + } + return false; +} +bool loadto(string &temp) +{ + toset=false; + to=0; + cout<<"ļ:"; + getline(cin,temp); + temp=nfaspace(temp); + if(checknum(temp,true)) + { + toset=true; + to=stoi(temp); + return true; + } + return false; +} +bool loadinname(string &temp) +{ + innameset=false; + inname=""; + cout<<"ļ:"; + getline(cin,temp); + temp=nfaspace(temp); + if(checkrule(temp,true)) + { + innameset=true; + inname=temp; + return true; + } + return false; +} +bool loadoutname(string &temp) +{ + outnameset=false; + outname=""; + cout<<"ļ:"; + getline(cin,temp); + temp=nfaspace(temp); + if(checkrule(temp,true)) + { + outnameset=true; + outname=temp; + return true; + } + return false; +} diff --git a/logo.h b/logo.h new file mode 100644 index 0000000..a98af65 --- /dev/null +++ b/logo.h @@ -0,0 +1,27 @@ +// Copyright (C) 2018 AdemJensen +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 3, +// or (at your option) any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +void LOGOout() +{ + system("title ת S2"); + cout<<"**********************************************************************************"<. + +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +string currentexe; + +#include"varibles.h" +#include"logo.h" +#include"system.h" +#include"checksys.h" +#include"loaddata.h" +#include"load.h" +#include"change.h" +#include"writeset.h" +#include"convertmain.h" + +int main(int argc,char *argv[]) +{ + cleardata(); + string stemp=argv[0]; + int slen=stemp.size()-1; + for(int i=slen;i>=0&&stemp[i]!='\\';i--) currentexe=stemp[i]+currentexe; + if(argc>1) + { + string option=argv[1]; + if(option=="-anti-reopen-mode") + { + /*fstream out; + openstream(out,"std.out","out"); + out<<"DOUBLE_CHECK_SYS"; + out.close();*/ + return 1; + } + if(option=="-quick-mode") + { + if(File_load(false,false)) + { + mainconversion(false); + cline();cout<<"[Ϣ]!"<. + +enum Color{red,blue,green,white,black,yellow}; +void pause() +{ + _getch(); +} +void clearall() +{ + system("cls"); + + cout<<"ת S2"< +void _warn(T s) +{ + changecolor(black,yellow); + cout< +void _ok(T s) +{ + changecolor(black,green); + cout< +void _err(T s) +{ + changecolor(black,red); + cout<maxium) now=1; + } + if(press==3) + { + clearall(); + return now; + } + if(press==4) + { + clearall(); + return 0; + } + clearall(); + } + +} +bool openstream(fstream &targetstream,string filename,string way) +{ + if(way=="in") targetstream.open(filename.c_str(),ios::in); + else targetstream.open(filename.c_str(),ios::out); + return targetstream.is_open(); +} +bool exist(string filename) +{ + ifstream checktemp; + checktemp.open(filename.c_str(),ios::in); + bool result=checktemp.is_open(); + checktemp.close(); + return result; +} +string itos(int a) +{ + string ans=""; + if(a==0) + { + ans="0"; + return ans; + } + while(a!=0) + { + char add=a%10+'0'; + ans=add+ans; + a=a/10; + } + return ans; +} +string exract(string s,int l,int r) +{ + if(l>r) return ""; + string ans; + for(int i=l;i<=r;i++) + { + ans+=s[i]; + } + return ans; +} +int stoi(string s) +{ + if(s.size()==0) return 0; + char str[1005]; + strcpy(str,s.c_str()); + return atoi(str); +} +void cleardata() +{ + exename="";// + inname="";//ļ + outname="";//ļ + from=9999;//ļʼ + to=0;//ļ + exenameset=false;// + innameset=false;//ļ + outnameset=false;//ļ + fromset=false;//ļʼ + toset=false;//ļ +} +void announcedata() +{ + cout<<"________________settings________________"<. + +string exename;// +string inname;//ļ +string outname;//ļ +int from;//ļʼ +int to;//ļ +bool exenameset;// +bool innameset;//ļ +bool outnameset;//ļ +bool fromset;//ļʼ +bool toset;//ļ diff --git a/writeset.h b/writeset.h new file mode 100644 index 0000000..792e5db --- /dev/null +++ b/writeset.h @@ -0,0 +1,44 @@ +// Copyright (C) 2018 AdemJensen +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 3, +// or (at your option) any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +void writesettings() +{ + int selection=keyboard("Ƿ񽫵ǰд\"settings.ini\"? (Esc=,Enter=)",false,2,27,13); + cline(); + if(selection==2) + { + fstream settings; + if(!openstream(settings,"settings.ini","out")) + { + _err("[]޷\"settings.ini\"!дʧ!\n"); + cout<<"[ȴӦ]"<