Skip to content

Merge main #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mandatory/inc/FileContent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* FileContent.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: eavedill <eavedill@student.42.fr> +#+ +:+ +#+ */
/* By: eavedill <eavedill@student.42barcelona> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/30 13:48:24 by eavedill #+# #+# */
/* Updated: 2024/06/30 14:55:08 by eavedill ### ########.fr */
/* Updated: 2024/07/02 23:16:02 by eavedill ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -33,7 +33,7 @@
class FileContent : public StatusCode
{
protected:
CGI *cgiModule;
CGI *cgiModule;
private:
std::string fileName;
std::string indexName;
Expand Down
6 changes: 4 additions & 2 deletions mandatory/inc/ListDir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* ListDir.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: eavedill <eavedill@student.42.fr> +#+ +:+ +#+ */
/* By: eavedill <eavedill@student.42barcelona> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/07 19:03:57 by eavedill #+# #+# */
/* Updated: 2024/06/30 14:47:57 by eavedill ### ########.fr */
/* Updated: 2024/07/02 23:13:22 by eavedill ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -32,6 +32,7 @@ class ListDir
std::size_t posToSend;
std::map<std::string, Attributes *> files;
bool isSendComplete;
bool isFileOpen;

public:
ListDir();
Expand All @@ -48,5 +49,6 @@ class ListDir
std::string getContentToSend();
size_t getSizeToSend();
void setSubdirectory(const std::string &);
bool getIsFileOpen();
};

20 changes: 14 additions & 6 deletions mandatory/src/FileContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* FileContent.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: eavedill <eavedill@student.42.fr> +#+ +:+ +#+ */
/* By: eavedill <eavedill@student.42barcelona> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/30 13:50:28 by eavedill #+# #+# */
/* Updated: 2024/06/30 15:26:47 by eavedill ### ########.fr */
/* Updated: 2024/07/02 23:25:35 by eavedill ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -49,10 +49,18 @@ std::string FileContent::getContent()
{
if (isAutoIndex && this->isInputDirectory())
{
isFileOpen = true;
content = listDir->getContentToSend();
this->setCompleteContentSize(content.size());
this->setIsSendComplete(listDir->getIsSendComlete());
isFileOpen = listDir->getIsFileOpen();
if (!isFileOpen)
{
content = this->getFileContentForStatusCode(NOT_FOUND_CODE);
this->setIsSendComplete(true);
}
else
{
content = listDir->getContentToSend();
this->setCompleteContentSize(content.size());
this->setIsSendComplete(listDir->getIsSendComlete());
}
return content;
}
else if (this->cgiModule->getIsCGI())
Expand Down
15 changes: 13 additions & 2 deletions mandatory/src/ListDir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* ListDir.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: eavedill <eavedill@student.42.fr> +#+ +:+ +#+ */
/* By: eavedill <eavedill@student.42barcelona> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/30 13:51:56 by eavedill #+# #+# */
/* Updated: 2024/06/30 15:25:36 by eavedill ### ########.fr */
/* Updated: 2024/07/02 23:14:13 by eavedill ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -125,6 +125,12 @@ void ListDir::openMasterListFile()
{
std::string filename = TEMPLATE_LIST_DIR;
file.open(filename.c_str(), std::ios::out | std::ios::binary);
if (!file.is_open())
{
isFileOpen = false;
return;
}
isFileOpen = true;
}

std::string ListDir::getContentToSend()
Expand Down Expand Up @@ -153,4 +159,9 @@ void ListDir::setSubdirectory(const std::string &subDir)
}
path += (path[path.size() -1] == '/') ? "" :"/";
this->setListOfFiles();
}

bool ListDir::getIsFileOpen()
{
return isFileOpen;
}
2 changes: 1 addition & 1 deletion mandatory/src/ListeningSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: eavedill <eavedill@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/30 13:51:47 by eavedill #+# #+# */
/* Updated: 2024/06/30 15:38:42 by eavedill ### ########.fr */
/* Updated: 2024/06/30 16:25:05 by eavedill ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
2 changes: 1 addition & 1 deletion mandatory/src/LocationParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int LocationParser::matchingLocation()
return NO_LOCATION;
}

off_t getFileSize(const std::string &filename)
long long getFileSize(const std::string &filename)
{
struct stat stat_buf;
int rc = stat(filename.c_str(), &stat_buf);
Expand Down
Loading