Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. --- PstProcessing_update2.cpp   Thu Mar 17 12:27:23 2016
  2. +++ PstProcessing_HaRT.cpp  Thu Mar 17 21:17:45 2016
  3. @@ -18,13 +18,16 @@
  4.     }
  5.  }
  6.  
  7. -static wstring GetDupTestFilename(wstring &baseName, int dupCounter)
  8. +static wstring GetDupTestFilename(wstring &baseName, int dupCounter, int noNameCounter)
  9.  {
  10.     wchar_t testName[MAX_PATH] = {0};
  11.     if (dupCounter > 0)
  12.         swprintf_s(testName, MAX_PATH, L"%s[%d].eml", baseName.c_str(), dupCounter);
  13.     else
  14.         swprintf_s(testName, MAX_PATH, L"%s.eml", baseName.c_str());
  15. +
  16. +   if(!*testName)  // swprintf_s() failed (e.g. if baseName contained garbage)
  17. +       swprintf_s(testName, MAX_PATH, L"Message%05d[%d].eml", noNameCounter, dupCounter);
  18.     return testName;
  19.  }
  20.  
  21. @@ -49,7 +52,8 @@
  22.             if (m.has_subject())
  23.             {
  24.                 wstring subj = m.get_subject();
  25. -               if (subj.length() > 200) subj.erase(200);
  26. +               if (subj.length() > 200)
  27. +                   subj.erase(200);
  28.                 strBaseFileName = subj;
  29.             }
  30.             else
  31. @@ -64,21 +68,22 @@
  32.             while (true)
  33.             {
  34.                 bool dupFound = false;
  35. -               wstring testName = GetDupTestFilename(strBaseFileName, dupCounter);
  36. +               wstring testName = GetDupTestFilename(strBaseFileName, dupCounter, NoNameCounter);
  37.                 for (auto it = fileInfoObj->Entries.begin(); it != fileInfoObj->Entries.end(); it++)
  38.                 {
  39.                     const PstFileEntry& prevEntry = *it;
  40.                     if ((prevEntry.Folder == parentPath) && (prevEntry.Name == testName))
  41.                     {
  42.                         dupFound = true;
  43. +                       break;
  44.                     }
  45.                 }
  46. -               if (!dupFound) break;
  47. -              
  48. +               if (!dupFound)
  49. +                   break;
  50.                 dupCounter++;
  51.             }
  52.  
  53. -           wstring strFileName = GetDupTestFilename(strBaseFileName, dupCounter);
  54. +           wstring strFileName = GetDupTestFilename(strBaseFileName, dupCounter, NoNameCounter);
  55.            
  56.             PstFileEntry fentry;
  57.             fentry.Type = fileInfoObj->ExpandEmlFile ? ETYPE_FOLDER : ETYPE_EML;