# include & ltvcl.h & gt
#雜註hdrstop
#包含“Main.h”
// -
#pragma包(smart_init)
#pragma資源" *。dfm "
t form 1 * form 1;
// -
_ _ fast call t form 1::t form 1(t component * Owner)
:t表單(所有者)
{
}
// -
bool __fastcall文件存在(正在註冊文件名)
{
HANDLE file HANDLE = create file(filename . c _ str(),
空,
文件共享讀取|
文件共享寫入,
空,
開放_現有,
文件屬性存檔|
文件_屬性_隱藏|
文件_屬性_正常|
文件屬性只讀|
文件屬性系統,
空
);
if(file HANDLE = = INVALID _ HANDLE _ VALUE)
返回false
close handle(file handle);
返回true
}
void __fastcall DoCvsIpReplace(正在註冊OldIp,正在註冊NewIp,正在註冊Path,TStatusBar *Status)
{
TSearchRec F;
TStringList *tls,*FileList,* TxtFile
正在註冊tmpPath
tmpPath = Path
file list = new TStringList();
嘗試{
文件列表-& gt;添加(tmpPath);
TLS = new TStringList();
嘗試{
while(文件列表-& gt;計數){
tmpPath = file list-& gt;字符串[0];
if(tmpPath== " ")
{
文件列表-& gt;刪除(0);
繼續;
}
狀態->;SimpleText = tmpPath
應用程序->;process messages();
if (tmpPath.c_str()[tmpPath。Length()-1]!='\\') {
tmp path = tmp path+" \ \ ";
}
memset(& amp;F,0,sizeof(F));
if (FindFirst(tmpPath+"*。*,faAnyFile,F)!=0)
繼續;
嘗試{
做{
//Sleep(1);
if(F.Name!="."& amp& ampf .名字!="..") {
if((F . Attr & amp;fad directory)= = fad directory)
//DoCvsIpReplace(OldIp,NewIp,tmpPath+F.Name+"\\ ",Status);
文件列表-& gt;add(tmp path+F . Name+" \ \ ");
否則{
if(F . Name = = " Root "){
狀態->;simple text = tmp path+F . Name;
應用程序->;process messages();
//TLS-& gt;LoadFromFile((tmp path+F . Name));
TLS-& gt;add(tmp path+F . Name);
//TLS-& gt;text = string place(TLS-& gt;Text,OldIp,NewIp,TReplaceFlags()& lt;& ltrfReplaceAll);
//TLS-& gt;SaveToFile((tmp path+F . Name));
}
}
}
}
while(FindNext(F)= = 0);
}
_ _最終{
FindClose(& amp;f);
}
文件列表-& gt;刪除(0);
}
TLS-& gt;SaveToFile(" c:\ \ replace . txt ");
嘗試{
while(TLS->;計數)
{
tmpPath = TLS-& gt;字符串[0];
if(tmp path = = " "){
TLS-& gt;刪除(0);
繼續;
}
狀態->;SimpleText= "處理...["+tmpPath+"]";
應用程序->;process messages();
txt file = new TStringList();
嘗試{
txt file-& gt;LoadFromFile((tmpPath));
txt file-& gt;text = string place(txt file-& gt;Text,OldIp,NewIp,TReplaceFlags()& lt;& ltrfReplaceAll);
txt file-& gt;SaveToFile((tmpPath));
}
_ _最終{
txt file-& gt;free();
}
TLS-& gt;刪除(0);
}
}
_ _最終{
TLS-& gt;SaveToFile(" c:\ \ replace . txt ");
}
}
_ _最終{
TLS-& gt;free();
}
}
_ _最終{
文件列表-& gt;free();
}
}
void _ _ fast call DoClearCvses(ansi ssing Dir,TStatusBar *Status,TMemo *LogMemo)
{
TSearchRec F;
正在註冊tmpDir
tmpDir = Dir
if (tmpDir。Length()==0) {
返回;
}
if(tmpDir.c_str()[tmpDir。Length()-1]!='\\')
tmpDir = tmpDir+" \ \ ";
if(FindFirst(tmpDir+"*。*,faAnyFile,F)!=0)
返回;
做{
//
狀態->;SimpleText= "正在搜索... "+tmpDir+F . Name;
應用程序->;process messages();
如果((F.Name!=".")& amp& amp(F .名字!=".."))
{
if(F.Name.UpperCase()=="CVS ")
{
//
setfile attributes(ansi string(tmpDir+F . Name))。c_str(),0);
if(remove directory(ansi string(tmpDir+F . Name))。c_str()))
日誌備忘錄-& gt;線條-& gt;add(" V:"+tmpDir+F . Name);
其他
日誌備忘錄-& gt;線條-& gt;add(" X:"+tmpDir+F . Name);
}
其他
{
DoClearCvses(tmpDir+F.Name+"\\ ",Status,log memo);
}
}
}
while(FindNext(F)= = 0);
FindClose(F);
}
void _ _ fast call t form 1::button 1 click(to object * Sender)
{
DoCvsIpReplace(txtOldIp-& gt;Text,txtNewIp-& gt;Text,txt directory-& gt;Text,status bar 1);
//"192.168.10.185","192.168.10.231"
}
// -
void _ _ fast call t form 1::button 2 click(to object * Sender)
{
DoClearCvses(txt directory-& gt;Text,StatusBar1,memo 1);
}
// -