String __fastcall TfrmMain::UniqueIdent() { _GUID AId; Sysutils::CreateGUID(AId); String S=Sysutils::GUIDToString(AId); return StringReplace(S.SubString(2,S.Length()-2),"-","",TReplaceFlags()<<rfReplaceAll); } TSyncItem * __fastcall TfrmMain::AddItem(const TSyncItem &src) { TSyncItem *AItem=new TSyncItem; if(src.Ident.Length()) AItem->Ident=src.Ident; else AItem->Ident=UniqueIdent(); AItem->SourceDir=src.SourceDir; AItem->DestDir=src.DestDir; AItem->IncludeFilter=src.IncludeFilter; AItem->ExcludeFilter=src.ExcludeFilter; AItem->Flags=src.Flags | SF_CHANGED; TJvChangeItem *ANotify=cnDirMonitor->Notifications->Add(); ANotify->Directory=src.SourceDir; ANotify->Actions=TJvChangeActions()<<caChangeFileName<<caChangeDirName<<caChangeAttributes<<caChangeSize<<caChangeLastWrite; ANotify->IncludeSubTrees=src.Flags&SF_SUBDIR; ANotify->OnChange=DoItemChange; AItem->Tag=(int)ANotify; String AExtFlags; if(AItem->Flags&SF_SUBDIR) AExtFlags=" , 包含子目录"; if(AItem->Flags&SF_HISTORY) AExtFlags+=" , 创建历史快照"; if(AItem->Flags&SF_BOTH) lbxItems->AddItem(AItem->SourceDir+" <=> "+AItem->DestDir+AExtFlags,(TObject *)AItem); else lbxItems->AddItem(AItem->SourceDir+" => "+AItem->DestDir+AExtFlags,(TObject *)AItem); return AItem; } |