fixed autoindex
This commit is contained in:
@@ -111,9 +111,6 @@ void Webserv::_get_file(Client *client, const std::string &path)
|
||||
}
|
||||
}
|
||||
|
||||
// i only sort of need &path...
|
||||
// def can improve but works for now...
|
||||
//void Webserv::_autoindex(Client *client, LocationConfig &location, std::string &path)
|
||||
void Webserv::_autoindex(Client *client, std::string &path)
|
||||
{
|
||||
std::cout << "made it to _autoindex\n";
|
||||
@@ -122,24 +119,25 @@ void Webserv::_autoindex(Client *client, std::string &path)
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
|
||||
// std::cout << "location root: " << client->assigned_location->root << " location path: "
|
||||
// << client->assigned_location->path << '\n';
|
||||
std::cout << "location root: " << client->assigned_location->root << " location path: "
|
||||
<< client->assigned_location->path << '\n';
|
||||
|
||||
std::cout << "Path in auto is: " << path << '\n';
|
||||
if ( (dir = opendir(path.c_str()) ) != NULL)
|
||||
{
|
||||
/* print all the files and directories within directory */
|
||||
dir_list.append(AUTOINDEX_START);
|
||||
dir_list.append(path);
|
||||
dir_list.append(AUTOINDEX_MID1);
|
||||
dir_list.append(path);
|
||||
dir_list.append(AUTOINDEX_MID2);
|
||||
/* print all the files and directories within directory */
|
||||
while ((ent = readdir (dir)) != NULL)
|
||||
{
|
||||
std::cout << "ent: " << ent->d_name << '\n';
|
||||
if (strcmp(".", ent->d_name) == 0)
|
||||
continue ;
|
||||
dir_list.append("<a href=\"");
|
||||
// dir_list.append(path);
|
||||
dir_list.append(client->assigned_location->path + "/");
|
||||
dir_list.append(ent->d_name);
|
||||
dir_list.append("\">");
|
||||
dir_list.append(ent->d_name);
|
||||
|
||||
Reference in New Issue
Block a user