Index and Autoindex work nicely, standarized way paths for root and location path are stored in config, still needs a little polishing prolly

This commit is contained in:
Me
2022-08-08 02:50:37 +02:00
parent cf69168a84
commit 9ee7205b95
13 changed files with 99 additions and 173 deletions

View File

@@ -30,22 +30,16 @@ class LocationConfig
public:
// canonic stuff?
// i thought this might fix the "non static member function"
// shit i'm getting with the comparator...
LocationConfig() {}
~LocationConfig() {}
std::string path;
std::string root;
std::string path; // /path and /path/ are fine
// i add trailing / if a dir
std::string root;
std::vector<std::string> index;
unsigned int allow_methods;
std::vector<std::string> cgi_ext; // php not .php
bool autoindex;
bool autoindex;
std::vector<std::string> upload_repo;
// wait if i can call several times, shouldn't it be a map?
// wait no there can only be 1 and i think it might have to be in
// location only...
@@ -79,12 +73,6 @@ public:
int comp_rhs = 0;
size_t tmp = 0;
// What are the rules...
// / is smaller than /test
// and /test/test1 is bigger than test
// so we want to count /
while ((tmp = this->path.find_first_of("/", tmp)) != std::string::npos)
{
++tmp;
@@ -101,23 +89,6 @@ public:
if (rhs.path[rhs.path.find_last_of("/") + 1] != '\0')
++comp_rhs;
// ok now we need to add a thing where we check for files vs folders
/* if (comp_lhs == comp_rhs)
{
if (path_is_valid(root + path) == 2)
--comp_lhs;
if (path_is_valid(rhs.root + rhs.path) == 2)
--comp_rhs;
}
*/
// std::cout << "comp_lhs: " << comp_lhs << " comp_rhs: " << comp_rhs
// << " bool res: " << (comp_lhs > comp_rhs) << "\n";
// i honestly can't tell you how or why but using > rather than <
// fixed all my problems
// the fact that the bool was always 0 before, and the correct order
// i want... super weird...
// return (comp_lhs > comp_rhs);
return (comp_lhs < comp_rhs); // right comparison ? not <= ?
};