Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. /**
  2. * CPSC 362 VCS Project
  3. * Copyright(C) 2018 Team TBD
  4. * @author Josh Gomberg jgomberg93@gmail.com
  5. * @author Michael Li limichael1099419@gmail.com
  6. * @author Frank Ngo frank.ngo@csu.fullerton.edu
  7. * @author Wellson Pan dihydrogenmonoxide1337@gmail.com
  8. *
  9. * main.cpp contains the main source code
  10. **/
  11.  
  12. #include "Header.h"
  13.  
  14. void createRepo(std::string source, std::string dest)
  15. {
  16. fs::path from{ source };
  17. fs::path to{ dest };
  18.  
  19. std::vector<fs::directory_entry> container(directorySize(source));
  20.  
  21. copy(fs::recursive_directory_iterator(from), fs::recursive_directory_iterator(), container.begin());
  22.  
  23. for (int i = 0; i < container.size(); i++)
  24. {
  25. //if the path points to a file
  26. //checksum the file to get ArtifactID
  27. if (fs::is_regular_file(container[i].path()))
  28. {
  29. //go through directory path to file and get its checksum
  30. std::ifstream infile(container[i].path().string());
  31. char c;
  32. int checkSum = 0;
  33. int counter = 0;
  34. while (infile.get(c))
  35. {
  36. checkSum += checksum(c, counter);
  37. counter++;
  38. }
  39. infile.close();
  40.  
  41. std::string s = container[i].path().string();
  42.  
  43. removeSubstrs(s, from.parent_path().string());
  44.  
  45. std::ifstream newInFile(container[i].path().string());
  46.  
  47. std::string outputFile = dest + "\\" + s + "\\";
  48.  
  49. fs::path temp{ outputFile.c_str() };
  50. fs::create_directories(outputFile);
  51.  
  52. outputFile = outputFile + std::to_string(checkSum) + "-L" + std::to_string(counter) + container[i].path().extension().string();
  53.  
  54. std::ofstream outFile(outputFile);
  55. std::string d;
  56. while (std::getline(newInFile, d))
  57. {
  58. outFile << d;
  59. outFile << "\n";
  60. }
  61. newInFile.close();
  62. outFile.close();
  63. }
  64. }
  65.  
  66. createManifest(dest);
  67. }
  68.  
  69. int main()
  70. {
  71. int input = prompt();
  72.  
  73. std::string source;
  74. std::cout << "Enter the source directory: ";
  75. std::getline(std::cin, source);
  76.  
  77. std::string dest;
  78. std::cout << "Enter the repo directory: ";
  79. std::getline(std::cin, dest);
  80.  
  81. while (input != 6)
  82. {
  83. if (input == 1)
  84. createRepo(source, dest);
  85. else if (input == 2)
  86. pushToRepo(dest, source);
  87. else if (input == 3)
  88. pullFromRepo(source, dest);
  89. else if (input == 4)
  90. labelManifest();
  91. else if (input == 5)
  92. Merge(source, dest);
  93. else
  94. std::cout << "Please enter a valid input" << std::endl;
  95. input = prompt();
  96. }
  97. std::cout << "Closing program" << std::endl;
  98.  
  99. system("Pause");
  100. return 0;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement