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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user