Location sorter works, fixed the compilation error i was having on this branch, now working on autoindex
This commit is contained in:
@@ -71,16 +71,12 @@ public:
|
||||
}
|
||||
|
||||
// works a lot better than using a compare function...
|
||||
// but it still doesn't work...
|
||||
// problem is the logic
|
||||
bool operator<(const LocationConfig& rhs) const
|
||||
{
|
||||
int comp_lhs = 0;
|
||||
int comp_rhs = 0;
|
||||
size_t tmp = 0;
|
||||
|
||||
// consider adding 1 to path that ends in a file not folder.
|
||||
|
||||
// What are the rules...
|
||||
// / is smaller than /test
|
||||
// and /test/test1 is bigger than test
|
||||
@@ -106,61 +102,25 @@ public:
|
||||
// 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 << "locations are equal\n";
|
||||
std::string tmp_path_lhs = root + path;
|
||||
std::cout << "root + path: " << tmp_path_lhs << '\n';
|
||||
|
||||
// const char *c_path_lhs = (root + path).substr(1).c_str();
|
||||
// could the problem be that i'm in the .hpp ?
|
||||
const char *c_path_lhs = tmp_path_lhs.substr(1).c_str();
|
||||
const char *c_path_rhs = (rhs.root + rhs.path).substr(1).c_str();
|
||||
|
||||
printf("lhs path: %s\n", c_path_lhs);
|
||||
printf("rhs path: %s\n", c_path_rhs);
|
||||
|
||||
struct stat sl;
|
||||
struct stat sr;
|
||||
|
||||
if (stat(c_path_lhs, &sl) == 0 && S_ISREG(sl.st_mode))
|
||||
{
|
||||
std::cout << "lhs is a file\n";
|
||||
--comp_lhs;
|
||||
}
|
||||
if (stat(c_path_rhs, &sr) == 0 && S_ISREG(sr.st_mode))
|
||||
{
|
||||
std::cout << "rhs is a file\n";
|
||||
--comp_rhs;
|
||||
}
|
||||
// do i need to free c_path's ???
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
std::cout << "comp_lhs: " << comp_lhs << " comp_rhs: " << comp_rhs \
|
||||
<< " bool res: " << (comp_lhs > comp_rhs) << "\n";
|
||||
// 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); // right comparison ? not <= ?
|
||||
// return (comp_lhs > comp_rhs);
|
||||
return (comp_lhs < comp_rhs); // right comparison ? not <= ?
|
||||
};
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
// ok it needs to go somewhere else
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user