// File: tylerkaraszewski[P]Argyle/FileReader.cpp
// Function: FileReader::openFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool FileReader::openFile(const string& fullPath)
{

  // Look up this file's size.
  struct stat fileStat;
  if(stat(fullPath.c_str(), &fileStat) == -1)
  {
    m_httpCode = 404;
    return false;
  }

  // If we *can* find this file's info, then we need to open the actual file.
  m_file = fopen(fullPath.c_str(), "r");
  if (m_file == NULL)
  {
    if (errno == EACCES)
    {
      m_httpCode = 403;
      return false;
    }
    else if (errno == ENOENT)
    {
      m_httpCode = 404;
      return false;
    }
    else
    {
      m_logger.logError("FileReader fopen error(" + Utils::llToString(errno) + "): " + strerror(errno));
      m_httpCode = 500;
      return false;
    }
  }
  
  m_contentLength = fileStat.st_size;
  m_lengthKnown = true;

  // Now we're ready to start reading.
  return true;
}

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x148(%rsp)
movq %rsi, 0x140(%rsp)
movq 0x148(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x140(%rsp), %rdi
callq 0x4190
movq %rax, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x4370
cmpl $-0x1, %eax
jne 0xefaf
movq 0x18(%rsp), %rax
movl $0x194, 0x14(%rax)      # imm = 0x194
movb $0x0, 0x157(%rsp)
jmp 0xf180
movq 0x140(%rsp), %rdi
callq 0x4190
movq %rax, %rdi
leaq 0x4989(%rip), %rsi      # 0x1394f
callq 0x4480
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x20(%rax)
cmpq $0x0, 0x20(%rax)
jne 0xf163
callq 0x4060
cmpl $0xd, (%rax)
jne 0xf005
movq 0x18(%rsp), %rax
movl $0x193, 0x14(%rax)      # imm = 0x193
movb $0x0, 0x157(%rsp)
jmp 0xf180
callq 0x4060
cmpl $0x2, (%rax)
jne 0xf028
movq 0x18(%rsp), %rax
movl $0x194, 0x14(%rax)      # imm = 0x194
movb $0x0, 0x157(%rsp)
jmp 0xf180
movq 0x18(%rsp), %rax
movq 0x70(%rax), %rax
movq %rax, 0x8(%rsp)
callq 0x4060
movslq (%rax), %rsi
leaq 0x30(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x10f70
movq 0x10(%rsp), %rdx
leaq 0x437e(%rip), %rsi      # 0x133d7
leaq 0x50(%rsp), %rdi
callq 0x6230
jmp 0xf065
leaq 0x3fa6(%rip), %rdx      # 0x13012
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x61e0
jmp 0xf07d
callq 0x4060
movl (%rax), %edi
callq 0x4150
movq %rax, %rdx
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x61e0
jmp 0xf0a0
movq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x10f40
jmp 0xf0b4
leaq 0x90(%rsp), %rdi
callq 0x4788
leaq 0x70(%rsp), %rdi
callq 0x4788
leaq 0x50(%rsp), %rdi
callq 0x4788
leaq 0x30(%rsp), %rdi
callq 0x4788
movq 0x18(%rsp), %rax
movl $0x1f4, 0x14(%rax)      # imm = 0x1F4
movb $0x0, 0x157(%rsp)
jmp 0xf180
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x28(%rsp)
movl %eax, 0x24(%rsp)
jmp 0xf157
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x28(%rsp)
movl %eax, 0x24(%rsp)
jmp 0xf14d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x28(%rsp)
movl %eax, 0x24(%rsp)
jmp 0xf143
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x28(%rsp)
movl %eax, 0x24(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x4788
leaq 0x70(%rsp), %rdi
callq 0x4788
leaq 0x50(%rsp), %rdi
callq 0x4788
leaq 0x30(%rsp), %rdi
callq 0x4788
jmp 0xf191
movq 0x18(%rsp), %rax
movq 0xe0(%rsp), %rcx
movq %rcx, 0x8(%rax)
movb $0x1, 0x10(%rax)
movb $0x1, 0x157(%rsp)
movb 0x157(%rsp), %al
andb $0x1, %al
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x28(%rsp), %rdi
callq 0x46b0
nopl (%rax,%rax)