// File: /workspace/github_cpp_makefile_star2_O2/mbourand[P]webserv/srcs/Methods/GetMethod.cpp
// Function: GetMethod::list_directory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::list<std::string> GetMethod::list_directory(const std::string& realPath)
{
	std::list<std::string> list;
	std::list<std::string> files;
	DIR* dir;
	struct dirent *ent;

	if ((dir = opendir(realPath.c_str())) == NULL)
	{
		Logger::print("Error while trying to open directory", NULL, INFO, VERBOSE);
		throw std::invalid_argument("Error while trying to open directory");
	}
	while ((ent = readdir(dir)) != NULL)
	{
		if (ent->d_type == DT_DIR)
			list.push_back(std::string(ent->d_name) + "/");
		else
			files.push_back(std::string(ent->d_name));
	}
	closedir(dir);
	files.sort(compare_nocase);
	list.sort(compare_nocase);
	std::list<std::string>::iterator it = files.begin();
	files.insert(it, list.begin(), list.end());
	return files;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
leaq 0x10(%rsp), %rax
movq %rax, 0x8(%rax)
movq %rax, (%rax)
andq $0x0, 0x10(%rax)
movq %rdi, 0x8(%rdi)
movq %rdi, (%rdi)
movq %rdi, 0x8(%rsp)
andq $0x0, 0x10(%rdi)
movq (%rdx), %rdi
callq 0x7730
testq %rax, %rax
je 0x9abe
movq %rax, %r14
leaq 0x68(%rsp), %r15
leaq 0x7(%rsp), %r12
leaq 0x2306c(%rip), %r13     # 0x2ca48
leaq 0x28(%rsp), %rbp
leaq 0x10(%rsp), %rbx
movq %r14, %rdi
callq 0x7740
testq %rax, %rax
je 0x9a5f
cmpb $0x4, 0x12(%rax)
jne 0x9a36
addq $0x13, %rax
movq %r15, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x8032
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xbe83
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xbe78
movq %rbp, %rdi
callq 0x79b8
movq %r15, %rdi
callq 0x79b8
jmp 0x99e6
addq $0x13, %rax
movq %rbp, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x8032
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0xbe78
movq %rbp, %rdi
callq 0x79b8
jmp 0x99e6
movq %r14, %rdi
callq 0x77b0
leaq -0x185(%rip), %rsi      # 0x98e9
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xbea2
leaq -0x199(%rip), %rsi      # 0x98e9
leaq 0x10(%rsp), %rdi
callq 0xbea2
movq (%rbx), %rsi
leaq 0x10(%rsp), %rcx
movq (%rcx), %rdx
movq %rbx, %rdi
callq 0xc058
leaq 0x10(%rsp), %rdi
callq 0x8f64
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2286f(%rip), %rsi     # 0x2c334
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x8032
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xbe10
leaq 0x48(%rsp), %rdi
callq 0x79b8
pushq $0x10
popq %rdi
callq 0x7290
movq %rax, %r14
leaq 0x22834(%rip), %rsi     # 0x2c334
movq %rax, %rdi
callq 0x7910
movq 0x394b9(%rip), %rsi     # 0x42fc8
movq 0x3949a(%rip), %rdx     # 0x42fb0
movq %r14, %rdi
callq 0x7830
movq %rax, %rbx
movq %r14, %rdi
callq 0x73d0
jmp 0x9b6a
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x9b60
jmp 0x9b67
jmp 0x9b67
jmp 0x9b67
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x9b60
movq %rax, %rbx
jmp 0x9b5b
jmp 0x9b67
jmp 0x9b67
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x79b8
leaq 0x68(%rsp), %rdi
callq 0x79b8
jmp 0x9b6a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x8f64
leaq 0x10(%rsp), %rdi
callq 0x8f64
movq %rbx, %rdi
callq 0x7860