// File: dwburer[P]CSCI-3232-File-System/FileSystem.cpp
// Function: FileSystem::changeDirectory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void FileSystem::changeDirectory(string dir) {
	if(!dir.compare("..")) {
		if(currentDirectory->hasParent) {
			currentDirectory = currentDirectory->getParent();
		} else {
			cout << dir << ": Invalid directory" << endl;
		}
	} else if(currentDirectory->contains(dir)){
		Entity* newDir = currentDirectory->children[dir];

		if(newDir->isDirectory) {
			currentDirectory = (Directory*) newDir;
			cout << "Current directory is now " << currentDirectory->getName() << endl;
		} else {
			cout << dir << ": Is not a directory" << endl;
		}
	} else {
		cout << "The requested destination does not exist " << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rsi, -0x80(%rbp)
movq %rdi, %rax
movq -0x80(%rbp), %rdi
movq %rdi, -0x78(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq 0x2921(%rip), %rsi      # 0x90e2
callq 0x30a0
cmpl $0x0, %eax
jne 0x6823
movq -0x70(%rbp), %rax
movq (%rax), %rax
testb $0x1, 0x70(%rax)
je 0x67f0
movq -0x70(%rbp), %rax
movq (%rax), %rdi
callq 0x4ea0
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, (%rax)
jmp 0x681e
movq -0x78(%rbp), %rsi
movq 0x67d5(%rip), %rdi      # 0xcfd0
callq 0x31f0
movq %rax, %rdi
leaq 0x2997(%rip), %rsi      # 0x91a1
callq 0x3220
movq %rax, %rdi
movq 0x67a7(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x699e
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x30f0
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x4e70
movb %al, -0x81(%rbp)
jmp 0x6860
leaq -0x30(%rbp), %rdi
callq 0x3140
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x6878
jmp 0x697a
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rax
movq (%rax), %rdi
addq $0x40, %rdi
callq 0x7780
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
testb $0x1, 0x31(%rax)
je 0x694a
movq -0x70(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, (%rax)
movq 0x671d(%rip), %rdi      # 0xcfd0
leaq 0x28fb(%rip), %rsi      # 0x91b5
callq 0x3220
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, -0xb0(%rbp)
movq (%rax), %rsi
leaq -0x68(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x4c10
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x31f0
movq %rax, -0xa0(%rbp)
jmp 0x68fc
movq -0xa0(%rbp), %rdi
movq 0x66b6(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x6911
leaq -0x68(%rbp), %rdi
callq 0x3140
jmp 0x6978
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3140
jmp 0x69a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x3140
jmp 0x69a7
movq -0x78(%rbp), %rsi
movq 0x667b(%rip), %rdi      # 0xcfd0
callq 0x31f0
movq %rax, %rdi
leaq 0x286b(%rip), %rsi      # 0x91cf
callq 0x3220
movq %rax, %rdi
movq 0x664d(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x699c
movq 0x664f(%rip), %rdi      # 0xcfd0
leaq 0x285c(%rip), %rsi      # 0x91e4
callq 0x3220
movq %rax, %rdi
movq 0x6629(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x699e
addq $0xb0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x3380