+ int nf=0;
+ //Iterates to see if they are in sync
+ for(iter=fileList.begin();iter!=fileList.end();++iter)
+ {
+ mSynchronizer->GetIgnoredFiles((*iter).key,ignoreList);
+ bool rec=true;
+ if((*iter).recursive=="0"){rec=false;}
+ CheckSyncDirectory((*iter).path,rec,repair,checkAttributes,ignoreList,attsModified,newFiles);
+
+ //For the new files, add them
+ for (i=newFiles.begin();i!=newFiles.end();++i)
+ {
+ mTimestampHandler->AddFile((*i), fs::last_write_time(*i), time(0));
+ if (IsHandledFile(*i))
+ {
+ std::stringstream removedOn;
+ removedOn<<time(0);
+ mSynchronizer->InsertIgnoreFile((*iter).key,(*i),"0",removedOn.str());
+ //Gets the number of files added
+ int files=atoi((mSynchronizer->GetAttribute("FILES_ADDED","ADD_OPS","ADD_KEY",(*iter).key)).c_str());
+ files=files+1;
+ std::stringstream out;
+ out<<files;
+ //Sets the new number of files
+ mSynchronizer->SetAttribute("FILES_ADDED","ADD_OPS",out.str(),"ADD_KEY",(*iter).key);
+ AddFile(*i);
+ }
+ }
+ nf+=newFiles.size();
+ newFiles.clear();
+
+ }
+ //Reports number of added files
+ mess<<"Files Added: "<<nf<<std::endl;
+
+ //Removes the necessary files and reports the results
+ if(ignoreList.size()>0)
+ {
+ tree::Node* node;
+ mTreeHandler->LoadChildren(NULL,4);
+ for(i=ignoreList.begin();i!=ignoreList.end();++i)
+ {
+ FindNode(mTreeHandler->GetTree().GetChildrenList()[0],3,"FullFileName",*i,node);
+ RemoveFile(node);
+ mTreeHandler->Remove(node);
+ }
+ }
+ mess<<"Files Removed: "<<ignoreList.size()<<std::endl;
+ //In the case that the user wants to check the attributes...
+ if(checkAttributes)
+ {
+ //... add to message the result of files that were modified.
+ mess<<"Files Modified: "<<attsModified.size()<<std::endl;
+ }
+ }
+ return mess.str();
+
+ }
+ //=======================================================================
+
+ void TreeHandlerImageAdder::CheckAttributes(bool repair, std::string& file, std::vector<std::string>& attsModified)
+ {
+ std::map< std::string, std::string> attr;
+ mTreeHandler->GetTree().GetDescriptor().BuildAttributeMap(attr);
+ mReader.ReadAttributes(file,attr);
+ tree::LevelDescriptor::AttributeDescriptorListType adl= mTreeHandler->GetTree().GetAttributeDescriptorList(mTreeHandler->GetTree().GetNumberOfLevels()-1);
+ tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
+ for (a = adl.begin();a!=adl.end();++a)
+ {
+ std::string databaseVal;
+ mTreeHandler->GetAttribute("Image","FullFileName",file,a->GetKey(),databaseVal);
+ std::string fileVal=attr.find(a->GetKey())->second;
+ if ( a->GetFlags()==0 && databaseVal.compare(fileVal)!=0 )
+ {
+ if(repair)
+ {
+ mTreeHandler->SetAttribute("Image",a->GetKey(),fileVal,"FullFileName", file);
+ }
+ attsModified.push_back(file);
+ }
+
+ }
+
+ }
+
+ //=======================================================================
+
+
+ void TreeHandlerImageAdder::FindNode(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node)
+ {
+ if(level>1)
+ {
+ std::vector<tree::Node*>::iterator iter;
+ for(iter=parent->GetChildrenList().begin();iter!=parent->GetChildrenList().end();++iter)
+ {
+ FindNode(*iter,level-1,searchParam,searchVal,node);
+ }
+ }
+ else
+ {
+ if(parent->GetAttribute(searchParam).compare(searchVal)==0)
+ {
+ node=parent;
+ }
+