#include "libfspp.hpp"

#include "gettext.hpp"
#include "global_options.hpp"
#include "common.hpp"
#include "print.hpp"

bool sort_order(const std::string& lhs, const std::string& rhs, bool lhs_is_dir, bool rhs_is_dir)
{
  GlobalOptions *go = GlobalOptions::get_instance();
  if (go->dir_order->values[go->dir_order->pos] == gettext("by name"))
    return (lhs <= rhs);
  else if (go->dir_order->values[go->dir_order->pos] == gettext("directories first")) {
    if ((lhs_is_dir && !rhs_is_dir) || 
	(!lhs_is_dir && rhs_is_dir))
      return (lhs_is_dir >= rhs_is_dir);
    else
      return (lhs <= rhs);
  } else {
    DebugPrint perror(gettext("Unknown sorting order"), 
		      Print::DEBUGGING, DebugPrint::CRITICAL, "LIBFS++");
    return false;
  }
}
