// File: metopa[P]HTTP_Server/src/content/CPathResolver.cpp
// Function: CPathResolver::resolve(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, EFileType&)
string CPathResolver::resolve( string& path, EFileType& ft ) {
	unwindPath( path );
	string realPath = substitutePath( path );
	struct stat info;

	if ( stat( realPath.c_str(), &info ) != 0 ) {
		int errNo = errno;
		switch ( errNo ) {
			case EFAULT:
			case ENAMETOOLONG:
			case ENOENT:
			case ENOTDIR:
				throw FileNotFoundException( path );
			case EACCES:
				throw PermissionDeniedException( path );
			default:
				throw FileErrorException( path );
		}
	}

	if ( access( realPath.c_str(), R_OK ) )
		throw PermissionDeniedException( path );

	if ( S_ISDIR( info.st_mode ) ) {
		if ( path.back() != '/' ) {
			path += '/';
			realPath += '/';
		}
		ft = FT_DIRECTORY;
		return realPath;
	}

	if ( S_ISREG( info.st_mode ) ) {
		string ext = getExt( realPath );
		if ( config.checkRegExt( ext ) )
			ft = FT_EXECUTABLE;
		else if ( config.checkScriptExt( ext ) )
			ft = FT_SCRIPT;
		else
			ft = FT_REGULAR;
		return realPath;
	}

	throw FileNotFoundException( path, "Is not file or directory. Error code 401 will be send." );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x120(%rbp)
movq %rdi, %rax
movq %rax, -0x130(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x128(%rbp)
movq -0x18(%rbp), %rsi
callq 0x1f0e0
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdi
movb $0x0, -0x21(%rbp)
movq -0x18(%rbp), %rdx
callq 0x1f2d0
movq -0x120(%rbp), %rdi
callq 0x6240
movq %rax, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x6480
cmpl $0x0, %eax
je 0x1f83e
callq 0x6080
movl (%rax), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
movl %eax, -0x134(%rbp)
subl $0x2, %eax
je 0x1f6fb
jmp 0x1f6bf
movl -0x134(%rbp), %eax
subl $0xd, %eax
je 0x1f776
jmp 0x1f6d0
movl -0x134(%rbp), %eax
subl $0xe, %eax
je 0x1f6fb
jmp 0x1f6dd
movl -0x134(%rbp), %eax
subl $0x14, %eax
je 0x1f6fb
jmp 0x1f6ea
movl -0x134(%rbp), %eax
subl $0x24, %eax
jne 0x1f7da
jmp 0x1f6fb
movl $0x48, %edi
callq 0x6280
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x140(%rbp)
movq -0x18(%rbp), %rsi
callq 0x16950
jmp 0x1f71d
movq -0x140(%rbp), %rdi
leaq 0x1eca5(%rip), %rsi     # 0x3e3d0
leaq -0x14c62(%rip), %rdx    # 0xaad0
callq 0x68e0
jmp 0x1fb30
movq -0x140(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
callq 0x63b0
jmp 0x1fb18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x1fb18
movl $0x48, %edi
callq 0x6280
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x148(%rbp)
movq -0x18(%rbp), %rsi
callq 0x168f0
jmp 0x1f798
movq -0x148(%rbp), %rdi
leaq 0x1ee52(%rip), %rsi     # 0x3e5f8
leaq -0x8e7d(%rip), %rdx     # 0x16930
callq 0x68e0
jmp 0x1fb30
movq -0x148(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
callq 0x63b0
jmp 0x1fb18
movl $0x48, %edi
callq 0x6280
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x150(%rbp)
movq -0x18(%rbp), %rsi
callq 0x16a10
jmp 0x1f7fc
movq -0x150(%rbp), %rdi
leaq 0x1ee06(%rip), %rsi     # 0x3e610
leaq -0x8dc1(%rip), %rdx     # 0x16a50
callq 0x68e0
jmp 0x1fb30
movq -0x150(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
callq 0x63b0
jmp 0x1fb18
movq -0x120(%rbp), %rdi
callq 0x6240
movq %rax, %rdi
movl $0x4, %esi
callq 0x68b0
cmpl $0x0, %eax
je 0x1f8c0
movl $0x48, %edi
callq 0x6280
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x158(%rbp)
movq -0x18(%rbp), %rsi
callq 0x168f0
jmp 0x1f87e
movq -0x158(%rbp), %rdi
leaq 0x1ed6c(%rip), %rsi     # 0x3e5f8
leaq -0x8f63(%rip), %rdx     # 0x16930
callq 0x68e0
jmp 0x1fb30
movq -0x158(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
callq 0x63b0
jmp 0x1fb18
movl -0xa0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x1f925
movq -0x18(%rbp), %rdi
callq 0x6390
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x1f908
movq -0x18(%rbp), %rdi
movl $0x2f, %esi
callq 0x6320
jmp 0x1f8f3
movq -0x120(%rbp), %rdi
movl $0x2f, %esi
callq 0x6320
jmp 0x1f906
jmp 0x1f908
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
movb $0x1, -0x21(%rbp)
movl $0x1, -0xd0(%rbp)
jmp 0x1faf6
movl -0xa0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x1fa0b
movq -0x120(%rbp), %rdx
movq -0x128(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x1f590
jmp 0x1f957
leaq 0x1fc82(%rip), %rdi     # 0x3f5e0
leaq -0xf0(%rbp), %rsi
callq 0x84f0
movb %al, -0x159(%rbp)
jmp 0x1f972
movb -0x159(%rbp), %al
testb $0x1, %al
jne 0x1f97e
jmp 0x1f9ad
movq -0x20(%rbp), %rax
movl $0x2, (%rax)
jmp 0x1f9ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x6310
jmp 0x1fb18
leaq 0x1fc2c(%rip), %rdi     # 0x3f5e0
leaq -0xf0(%rbp), %rsi
callq 0x8550
movb %al, -0x15a(%rbp)
jmp 0x1f9c8
movb -0x15a(%rbp), %al
testb $0x1, %al
jne 0x1f9d4
jmp 0x1f9e0
movq -0x20(%rbp), %rax
movl $0x3, (%rax)
jmp 0x1f9ea
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x1f9ec
movb $0x1, -0x21(%rbp)
movl $0x1, -0xd0(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x6310
jmp 0x1faf6
movb $0x1, -0x112(%rbp)
movl $0x48, %edi
callq 0x6280
movq %rax, -0x178(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0x111(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x6930
movq -0x168(%rbp), %rdx
leaq 0xcbd7(%rip), %rsi      # 0x2c626
leaq -0x110(%rbp), %rdi
callq 0xa9d0
jmp 0x1fa5d
movq -0x170(%rbp), %rsi
movq -0x178(%rbp), %rdi
leaq -0x110(%rbp), %rdx
callq 0xaa80
jmp 0x1fa79
movq -0x178(%rbp), %rdi
movb $0x0, -0x112(%rbp)
leaq 0x1e942(%rip), %rsi     # 0x3e3d0
leaq -0x14fc5(%rip), %rdx    # 0xaad0
callq 0x68e0
jmp 0x1fb30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x1fad1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x6310
leaq -0x111(%rbp), %rdi
callq 0x6550
testb $0x1, -0x112(%rbp)
jne 0x1fae8
jmp 0x1faf4
movq -0x178(%rbp), %rdi
callq 0x63b0
jmp 0x1fb18
testb $0x1, -0x21(%rbp)
jne 0x1fb08
movq -0x120(%rbp), %rdi
callq 0x6310
movq -0x130(%rbp), %rax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x120(%rbp), %rdi
callq 0x6310
movq -0xc8(%rbp), %rdi
callq 0x6920