Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. /**
  2. *
  3. * @File :
  4. *
  5. * @Author : A. B. Dragut
  6. *
  7. * @Synopsis : modelmain
  8. **/
  9.  
  10. #include <string>
  11. #include <exception>
  12. #include <iostream>
  13.  
  14. #include <unistd.h> // getdtablesize()
  15. #include <sys/time.h> // fd_set
  16.  
  17. #include "nsSysteme.h"
  18. #include "CExc.h"
  19.  
  20. using namespace nsSysteme;
  21. using namespace std;
  22.  
  23. size_t donneTailleMorceau(char * method, char * filename){
  24. struct stat S;
  25.  
  26. Stat(filename,&S);
  27.  
  28. std::string m = method;
  29.  
  30. if(m == "all"){
  31. return S.st_size;
  32. }else if(m == "block"){
  33. return S.st_blksize;
  34. }
  35.  
  36. return 1;
  37. }
  38.  
  39. int main(int argc, char * argv [])
  40. {
  41. try {
  42. //exo_3.run <methode> <file> <destination>
  43. std::string method = argv[1];
  44. std::string file = argv[2];
  45. std::string destination = argv[3];
  46.  
  47. size_t taille = donneTailleMorceau(argv[1], argv[2]);
  48. nsFctShell::FileCopy(argv[3], argv[2], taille);
  49.  
  50. return 0;
  51. }
  52. catch (const CExc & Exc) {
  53. cerr <<Exc<< endl;
  54. return errno;
  55. }
  56. catch (const exception & Exc) {
  57. cerr << "Exception : " << Exc.what () << endl;
  58. return 1;
  59. }
  60. catch (...) {
  61. cerr << "Exception inconnue recue dans la fonction main()"
  62. << endl;
  63. return 1;
  64. }
  65.  
  66.  
  67. } // main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement