diff --git a/Protocol.cpp b/Protocol.cpp index f481d35daac77ac2356ef705a9dcca73f9f89525..93f1f4a768fb6ce6630e58a2069cf1ae4d2e2d3a 100644 --- a/Protocol.cpp +++ b/Protocol.cpp @@ -14,6 +14,16 @@ double timestamp(void) { return ((double)(tp.tv_sec + tp.tv_usec/1000000.0)); } +void printErrors(char error){ + if(error == DIR_ERR){ + cout << "Arquivo ou diretório inexistente."<<endl; + }else if(error == PERM_ERR){ + cout << "Você não tem permissão."<<endl; + }else if(error == SPACE_ERR){ + cout << "Espaço insuficiente no disco."<<endl; + } +} + vector<Message> Protocol::getMessages(){ return messages; } @@ -221,7 +231,8 @@ int Protocol::receive(int sockt, int type, int window, bool dataEndable){ nextSequence = (messages.back().sequence.to_ulong()+1)%(MAXSIZE+1); } } else if(status == ERROR) { - cout << "ERROR: " << messages.back().getDataAsString() << endl; + cout << "ERROR: "; + printErrors(messages.back().data[0]); return -1; } }while(status != end); diff --git a/client.cpp b/client.cpp index 954f302e378cf0044f9b68a1d5f5c09125f717ca..4fb1167842f7048c367e3ab25329cd30ceddcba0 100644 --- a/client.cpp +++ b/client.cpp @@ -45,7 +45,7 @@ int main(){ args = line.substr(pos+1, line.size()); if(fexists(args)) { string size = to_string(filesize(args)); - cout << "ARQUIVO: " << args << "|\tTAMANHO:" << size << endl; + // cout << "ARQUIVO: " << args << "|\tTAMANHO:" << size << endl; sendProtocol.setData(vector<BYTE>(args.begin(), args.end()), PUT); sendProtocol.sendMessage(sockt, 0); int error = receiveProtocol.receive(sockt, OK, WAIT_STOP, false); diff --git a/dirFunctions.cpp b/dirFunctions.cpp index 845835a9a59367170f7d2d3c3ae661caef4e6810..b028dda409416c18417424273f33534318be0ef5 100644 --- a/dirFunctions.cpp +++ b/dirFunctions.cpp @@ -59,7 +59,7 @@ bool hasEnoughSpace(int size){ void writeFile(string path, vector<BYTE>data){ - cout << "path: "<< path<<endl; + // cout << "path: "<< path<<endl; string strData(data.begin(), data.end()); ofstream file(path); if (file.is_open()){