diff --git a/mandatory/inc/StatusCode.hpp b/mandatory/inc/StatusCode.hpp index 2b7eb5d..b7c848e 100644 --- a/mandatory/inc/StatusCode.hpp +++ b/mandatory/inc/StatusCode.hpp @@ -6,7 +6,7 @@ /* By: eavedill +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/30 13:49:24 by eavedill #+# #+# */ -/* Updated: 2024/06/30 13:49:24 by eavedill ### ########.fr */ +/* Updated: 2024/07/04 07:19:29 by eavedill ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,4 +37,5 @@ class StatusCode { void setCurrentCode(int); int getCurrentCode(); void loadErrorPageFromDir(const ExtendedString &); + ExtendedString getInternContent(); }; \ No newline at end of file diff --git a/mandatory/src/ListDir.cpp b/mandatory/src/ListDir.cpp index d1d5b75..378dd65 100644 --- a/mandatory/src/ListDir.cpp +++ b/mandatory/src/ListDir.cpp @@ -97,6 +97,22 @@ void ListDir::setContentToList() { contentToSend = ""; char buffer[MAX_SENT_BYTES]; + if (!isFileOpen) + { + contentToSend = "\n"; + contentToSend += "\n"; + contentToSend += " List Directory Error\n"; + contentToSend += "\n"; + contentToSend += "\n"; + contentToSend += "\n"; + contentToSend += "\n"; + contentToSend += "\n"; + contentToSend += "

List directory template not found

Please generate the file ./templates/dir_list.html or define it on ListDir.hpp

\n"; + contentToSend += "\n"; + contentToSend += "\n"; + isFileOpen = true; + return ; + } while(file.read(buffer, MAX_SENT_BYTES)) { contentToSend.append(buffer, file.gcount()); @@ -135,7 +151,9 @@ void ListDir::openMasterListFile() std::string ListDir::getContentToSend() { - std::string subStrToSend = contentToSend.substr(posToSend, MAX_SENT_BYTES); + std::string subStrToSend; + subStrToSend = contentToSend.substr(posToSend, MAX_SENT_BYTES); + if(posToSend + MAX_SENT_BYTES >= contentToSend.size()) posToSend = contentToSend.size(); else diff --git a/mandatory/src/StatusCode.cpp b/mandatory/src/StatusCode.cpp index 7a13dfd..92e76ab 100644 --- a/mandatory/src/StatusCode.cpp +++ b/mandatory/src/StatusCode.cpp @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* StatusCode.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: eavedill +#+ +:+ +#+ */ +/* By: eavedill +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/30 13:51:07 by eavedill #+# #+# */ -/* Updated: 2024/06/30 15:15:28 by eavedill ### ########.fr */ +/* Updated: 2024/07/04 07:37:03 by eavedill ### ########.fr */ /* */ /* ************************************************************************** */ @@ -86,6 +86,7 @@ void StatusCode::setFileContentForStatusCode(int CodeNumber, const std::string & } else { + content = this->getInternContent(); printLog("WARNING", CodeFileContent + " File does not exist.\t Set error page to default " CHR_GREEN "GET" RESET " value"); } mapCodesFileContent[CodeNumber] = content; @@ -139,4 +140,22 @@ void StatusCode::loadErrorPageFromDir(const ExtendedString &dir) } } closedir(dp); +} + +ExtendedString StatusCode::getInternContent() +{ + ExtendedString content; + content = "\n"; + content += "\n"; + content += " {{ErrorCode}}\n"; + content += "\n"; + content += "\n"; + content += "\n"; + content += "\n"; + content += "\n"; + content += "\n"; + content += "

This is an internal text defined.

{{ErrorCode}}.

Please generate the file ./templates/error_template.html or define it on statusCodesDefinition.hpp
\n"; + content += "\n"; + content += "\n"; + return content; } \ No newline at end of file