ok Location sorting and processing is finally working as expected, still a few things to add like error_pages but will get there soon

This commit is contained in:
Me
2022-08-05 21:46:46 +02:00
parent 9ac14aa1aa
commit f7dc5ccde4
12 changed files with 119 additions and 114 deletions

View File

@@ -86,3 +86,43 @@ std::string http_methods_to_str(unsigned int methods)
return (str);
}
int path_is_valid(std::string path)
{
std::string i_path = path.substr(1);
const char *tmp_path = i_path.c_str();
struct stat s;
if (stat(tmp_path, &s) == 0)
{
if (S_ISREG(s.st_mode))
{
// std::cout << "is a file\n";
return (2);
}
else if (S_ISDIR(s.st_mode))
{
// std::cout << "is a Dir\n";
return (1);
}
}
/*
if (stat(tmp_path, &s) == 0 && S_ISREG(s.st_mode)) // a File
{
std::cout << "is a file\n";
return (2);
}
else if (stat(tmp_path, &s) == 0 && S_ISDIR(s.st_mode)) // A Folder
{
std::cout << "is a Dir\n";
return (1);
}
*/
// std::cout << "path is neither dir nor file\n";
return (0);
}