Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <iostream>
  5. #include <Windows.h>
  6. #include <stdlib.h>
  7. #include <io.h>
  8.  
  9. using namespace std;
  10.  
  11. class MD6
  12. {
  13. public:
  14.    
  15.     string folderPath;
  16.     void CreateFilesList()
  17.     {
  18.         WIN32_FIND_DATAW findData;
  19.         HANDLE hf;
  20.  
  21.         neededFolderPath = folderPath + "*.*";
  22.  
  23.         wstring s(neededFolderPath.begin(), neededFolderPath.end());
  24.         hf = FindFirstFileW(s.c_str(), &findData);
  25.  
  26.         do { //
  27.             if (findData.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE)
  28.             {
  29.  
  30.                 wcstombs(s2, findData.cFileName, 249);
  31.  
  32.  
  33.                 fileName = s2;
  34.                 filePath = folderPath + fileName;
  35.  
  36.                 filePath = Exe + filePath;
  37.                 char *hashingFile = &filePath[0u];
  38.                 ofstream Name("Name.txt");
  39.                 wcout << endl << "File name:  " << findData.cFileName << endl;
  40.                 char *N = &fileName[0u];
  41.                 Name << N;
  42.                 Name.close();
  43.                 printf("MD6 Hash =");
  44.                 system(hashingFile);
  45.                 char buff[64];
  46.                
  47.  
  48.                 string str;
  49.                 int i = 0;
  50.                 string path;
  51.                 char hash[64];
  52.                
  53.                 string name;
  54.                
  55.                 ifstream Name_check("Name.txt");
  56.                 Name_check >> name;
  57.                 ifstream Hash("FName.txt");
  58.                 Hash >> buff;
  59.                 string H = string(hash);
  60.                 ifstream file;
  61.                
  62.                 file.open("files_list.txt");
  63.                 for (str; getline(file, str);)
  64.                 {
  65.                     i++;
  66.  
  67.                     if (i % 2 != 0)
  68.                     {
  69.                         file >> str;
  70.                         path = str;
  71.                         if (path == name)
  72.                         {
  73.                             i++;
  74.                             file>>str;
  75.                             H = str;
  76.                             string B = buff;
  77.                             if (B == H)
  78.                             {
  79.                                 cout << "Файл не повреждён!!!\n";
  80.                                
  81.                             }  
  82.                             else{ cout << "Файл повреждён или не существует"; }
  83.                             Hash.close();
  84.                             i = i - 1;
  85.                             cout << i;
  86.                         }
  87.                     }Name.close();
  88.                    
  89.                 }
  90.                 file.close();
  91.             }    
  92.         } while (FindNextFileW(hf, &findData));
  93.         FindClose(hf);
  94.  
  95.     }
  96. private:
  97.     string Exe = "MD6.exe ", fileName, neededFolderPath, filePath;
  98.     int size;
  99.     char s2[];
  100.  
  101.     long FileSize(string filePath)
  102.     {
  103.         char *tempSize = &filePath[0u];
  104.         long nFileLen = 0;
  105.         struct _finddata_t fData;
  106.         int res = _findfirst(tempSize, &fData);
  107.         if (res > 0)
  108.             nFileLen = fData.size;
  109.         return(nFileLen);
  110.     }
  111. }MD6;
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118. int main()
  119. {
  120.  
  121.     setlocale(LC_ALL, "rus");
  122.  
  123.  
  124.     cout << "Enter directory path: " << endl;
  125.     cin >> MD6.folderPath;
  126.     MD6.CreateFilesList();
  127.  
  128.     system("pause");
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement