Advertisement
Guest User

Erro

a guest
Apr 21st, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. //main.cpp
  2.  
  3. #include <iostream>
  4. #include "errors.h"
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10.     cout << "\e[H\e[2J\033[1m" << "* * * JENT - Tecnologia a serviço da humanidade [www.jent.com.br] * * *" << endl;
  11.     cout << "\033[1m====================================\nPAFKIT versão 0.12 [Desenvolvimento]\n====================================" << "\033[0m" << endl;
  12.     cout << "\033[1mValidador de arquivos de sistema de PAF para o Ato COTEPE 46/2014\n" << "\033[0m" << endl;
  13.  
  14.     Errors err;
  15.     ifstream generic;
  16.  
  17.     //  *** Tratamento de erros ***
  18.     // Se o erro foi não ter digitado o nome do arquivo
  19.     if(!argv[1])
  20.         {
  21.             err.errorArgv1();
  22.         } else {
  23.     //Se o erro é não estar podendo abrir o arquivo
  24.             generic.open(argv[1]);
  25.  
  26.             if(!generic.is_open())
  27.             {
  28.                 err.errorOpening(argv[1]);
  29.             }
  30. }
  31.     return 0;
  32. }
  33.  
  34. //errors.h
  35.  
  36. #ifndef ERRORS_H
  37. #define ERRORS_H
  38.  
  39. class Errors
  40. {
  41. public:
  42.     Errors();
  43.     int errorArgv1();
  44.     int errorOpening(char *argvError);
  45. };
  46.  
  47. #endif // ERRORS_H
  48.  
  49. //errors.cpp
  50.  
  51. #include "errors.h"
  52. #include <iostream>
  53.  
  54. using namespace std;
  55.  
  56. Errors::Errors()
  57. {
  58.  
  59. }
  60.  
  61. int Errors::errorArgv1()
  62. {
  63.     cout << "ERRO 001: Você não digitou o nome e/ou caminho do arquivo a ser analisado. Tente novamente.\n" << endl;
  64.     return 1;
  65. }
  66.  
  67. int Errors::errorOpening(char *argvError)
  68. {
  69.     ifstream generic;
  70.  
  71.     cout << "ERRO 004: Não foi possível ler o arquivo " << argvError << ". Uma destas possibilidades pode ser a causa do problema:\n --> Este se encontra corrompido;\n --> Você não possui permissão de leitura;\n --> Não é um arquivo texto;\n --> Não está no formato exigido no ATO COTEPE.\nVerifique uma destas possibilidades e tente novamente.\n" << endl;
  72.     generic.clear();
  73.     return 1;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement