void AddPath(Path* p) { paths.push_back(shared_ptr < Path > (p)); }
// --- std::string VSWContentPrjSaver::extractPathsFrom (VSWContentProjectPt cntPrj, const std::string& pToFile) { #ifdef __DEBUGSYSTEM __KEEPENTRYSIMPLETRACE #endif // The chain of paths, returned at the end of the method. std::string result (__NULL_STRING__); // Variables used only temporaly to iterate over the elements... PathsList finalPaths; PathsList::const_iterator i; // Iterates over all the data paths, // generating the real rel path, and only keeping one versión of that- finalPaths = PathsList (); for (i = _temporalPathsForData.begin (); i != _temporalPathsForData.end (); i++) { // First, get only the path of the xml file keeped... std::string relPath = std::string (".") + std::string (__PATH_SEPARATOR__); std::string fileName = (*i); if (fileName.find_last_of (std::string (__PATH_SEPARATOR__)) != -1) relPath = fileName.substr (0, fileName.find_last_of (__PATH_SEPARATOR__)); relPath = relPathFor (relPath, _theData -> valueForVariable (std::string (__VARBASICPATH__))); // The look for the recient found structure int the just existing ones // If it is not found, then it will be inserted. QBOOLEAN existsPath = QFALSE; for (PathsList::const_iterator j = finalPaths.begin (); j != finalPaths.end () && !existsPath; j++) if ((*j) == relPath) existsPath = QTRUE; if (!existsPath) { finalPaths.push_back (relPath); result += std::string ("\t\t<") + std::string (__PRJCONTENTPATHXML_TAGNAME__) + std::string (" ") + std::string (__PRJPATHXML_VARRELPATH__) + std::string ("=\"") + relPath + std::string ("\"/>\n"); } } // Iterates over all the content paths, // generating the real rel path, and only keeping one versión of that- finalPaths = PathsList (); for (i = _temporalPathsForContents.begin (); i != _temporalPathsForContents.end (); i++) { // First, get only the path of the xml file keeped... std::string relPath = std::string (".") + std::string (__PATH_SEPARATOR__); std::string fileName = (*i); if (fileName.find_last_of (std::string (__PATH_SEPARATOR__)) != -1) relPath = fileName.substr (0, fileName.find_last_of (__PATH_SEPARATOR__)); relPath = relPathFor (relPath, _theData -> valueForVariable (std::string (__VARBASICPATH__))); // The look for the recient found structure int the just existing ones // If it is not found, then it will be inserted. QBOOLEAN existsPath = QFALSE; for (PathsList::const_iterator j = finalPaths.begin (); j != finalPaths.end () && !existsPath; j++) if ((*j) == relPath) existsPath = QTRUE; if (!existsPath) { finalPaths.push_back (relPath); result += std::string ("\t\t<") + std::string (__PRJCONTENTSDESCRIPTORPATHXML_TAGNAME__) + std::string (" ") + std::string (__PRJPATHXML_VARRELPATH__) + std::string ("=\"") + relPath + std::string ("\"/>\n"); } } // Iterates over all the sequence paths, // generating the real rel path, and only keeping one versión of that- finalPaths = PathsList (); for (i = _temporalPathsForSequences.begin (); i != _temporalPathsForSequences.end (); i++) { // First, get only the path of the xml file keeped... std::string relPath = std::string (".") + std::string (__PATH_SEPARATOR__); std::string fileName = (*i); if (fileName.find_last_of (std::string (__PATH_SEPARATOR__)) != -1) relPath = fileName.substr (0, fileName.find_last_of (__PATH_SEPARATOR__)); relPath = relPathFor (relPath, _theData -> valueForVariable (std::string (__VARBASICPATH__))); // The look for the recient found structure int the just existing ones // If it is not found, then it will be inserted. QBOOLEAN existsPath = QFALSE; for (PathsList::const_iterator j = finalPaths.begin (); j != finalPaths.end () && !existsPath; j++) if ((*j) == relPath) existsPath = QTRUE; if (!existsPath) { finalPaths.push_back (relPath); result += std::string ("\t\t<") + std::string (__PRJSEQUENCESDESCRIPTORPATHXML_TAGNAME__) + std::string (" ") + std::string (__PRJPATHXML_VARRELPATH__) + std::string ("=\"") + relPath + std::string ("\"/>\n"); } } // Iterates over all the schedulings paths, // generating the real rel path, and only keeping one versión of that- finalPaths = PathsList (); for (i = _temporalPathsForSchedulings.begin (); i != _temporalPathsForSchedulings.end (); i++) { // First, get only the path of the xml file keeped... std::string relPath = std::string (".") + std::string (__PATH_SEPARATOR__); std::string fileName = (*i); if (fileName.find_last_of (std::string (__PATH_SEPARATOR__)) != -1) relPath = fileName.substr (0, fileName.find_last_of (__PATH_SEPARATOR__)); relPath = relPathFor (relPath, _theData -> valueForVariable (std::string (__VARBASICPATH__))); // The look for the recient found structure int the just existing ones // If it is not found, then it will be inserted. QBOOLEAN existsPath = QFALSE; for (PathsList::const_iterator j = finalPaths.begin (); j != finalPaths.end () && !existsPath; j++) if ((*j) == relPath) existsPath = QTRUE; if (!existsPath) { finalPaths.push_back (relPath); result += std::string ("\t\t<") + std::string (__PRJSCHEDULINGSDESCRIPTORPATHXML_TAGNAME__) + std::string (" ") + std::string (__PRJPATHXML_VARRELPATH__) + std::string ("=\"") + relPath + std::string ("\"/>\n"); } } #ifdef __DEBUGSYSTEM __KEEPEXITSIMPLETRACE #endif // Return the result return (result); }
void Process() { PathListIt it = paths.begin(); while (it != paths.end()) { getFolderContent(*it); ++it; } logInfo(L"Files to process:\t%8llu\n", data.size()); logDebug(L""); std::sort(data.begin(), data.end(), CompareBySizeAndTime); std::pair<FilesListIt, FilesListIt> bounds; FilesListIt srch = data.begin(); while (srch != data.end()) { logCounter(L"Files left:\t%8llu", std::distance(srch, data.end())); bounds = std::equal_range(srch, data.end(), *srch, CompareBySize); if (std::distance(bounds.first, bounds.second) == 1) { ++Statistics::getInstance()->filesFoundUnique; data.erase(bounds.first); } else { while (srch != bounds.second) { FilesListIt it = srch; ++it; shared_ptr<File>& f1 = *srch; while (it != bounds.second) { shared_ptr<File>& f2 = *it; AutoUTF buf1(f1->path()); AutoUTF buf2(f2->path()); { ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN); logDebug(L"Comparing files [size = %I64u]:\n", f1->size()); } logDebug(L" %s\n", buf1.c_str()); logDebug(L" %s\n", buf2.c_str()); ++Statistics::getInstance()->fileCompares; f1->refresh(); f2->refresh(); if (AttrMustMatch && f1->attr() != f2->attr()) { { ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); logDebug(L" Attributes of files do not match, skipping\n"); } Statistics::getInstance()->fileMetaDataMismatch++; ++it; break; } if (TimeMustMatch && f1->mtime() != f2->mtime()) { { ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); logDebug(L" Modification timestamps of files do not match, skipping\n"); } Statistics::getInstance()->fileMetaDataMismatch++; ++it; break; } if (!isSameVolume(*f1, *f2)) { { ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); logDebug(L" Files ignored - on different volumes\n"); } ++Statistics::getInstance()->filesOnDifferentVolumes; ++it; break; } if (f1 == f2) { ++Statistics::getInstance()->fileAlreadyLinked; { ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_GREEN); logDebug(L" Files ignored - already linked\n"); } ++it; break; } if (f1->size() > FirstBlock) { if (!f1->LoadHashMini()) { break; } if (!f2->LoadHashMini()) { it = data.erase(it); continue; } } else { if (!f1->LoadHashFull()) { break; } if (!f2->LoadHashFull()) { it = data.erase(it); continue; } } if (isIdentical(*f1, *f2)) { ++Statistics::getInstance()->fileContentSame; if (logLevel == LOG_VERBOSE) { { ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN); logVerbose(L"Comparing files [size = %I64u]:\n", f1->size()); } logVerbose(L" %s\n", buf1.c_str()); logVerbose(L" %s\n", buf2.c_str()); } { ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); logVerbose(L" Files are equal, hard link possible\n"); } if (hardlink) { f1->hardlink(*f2); } Statistics::getInstance()->FreeSpaceIncrease += f1->size(); it = data.erase(it); } else { { ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); logDebug(L" Files differ in content (hash)\n"); } Statistics::getInstance()->hashComparesHit1++; ++it; } } srch = data.erase(srch); } } srch = bounds.second; } logCounter(L" "); }