diff --git a/include/connectionRawSocket.h b/include/connectionRawSocket.h
index 8db07962a8a6e351021b54033e889442d25289f0..bfa883bd1170af726f6179308dd1ab244037ad46 100644
--- a/include/connectionRawSocket.h
+++ b/include/connectionRawSocket.h
@@ -13,6 +13,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <errno.h>
 #include <iostream>
 #include <sstream>
 #include <vector>
diff --git a/src/messages.cpp b/src/messages.cpp
index 5003bb98e4f8a3956de7c873aa0a4e0a5d696ee1..fc0e7be827eded015fbe1844e1bc44c74410e716 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -506,14 +506,14 @@ int Message::receiveCD(unsigned char* dir){
   int errorTest;
   SubMessage resposta;
 
-  if(testaSeDirExiste()){
-    if(testaSeHaPermissao()){
-      errorTest = cdMini((char*) dir);
+  errorTest = cdMini((char*) dir);
+  if(errno = ENOENT){
+    if(errno = EPERM){
       if (errorTest == -1){
-        resposta.setData((unsigned char*)'',0,0); // Manda um Nack
+        resposta.setData((unsigned char*)'0',0,0); // Manda um Nack
         send(soquete,resposta.objToString(),resposta.getSize()+4, 0);
       } else {
-        resposta.setData((unsigned char*)'',8,0); // Manda um OK
+        resposta.setData((unsigned char*)'0',8,0); // Manda um OK
         send(soquete,resposta.objToString(),resposta.getSize()+4, 0);
       }
     } else { // Não há permissão para acessar o diretorio