// File: /workspace/github_cpp_makefile_star2_O2/vianna274[P]dropbox/src/Client.cpp
// Function: Dropbox::Client::get_sync_dir()
void Client::get_sync_dir(){

	this->createSyncDir();
	
	DIR * dir;
    struct dirent *ent;
    if ((dir = opendir (this->getSyncDirPath().c_str())) != NULL) {
        while ((ent = readdir (dir)) != NULL) {
            if(ent->d_type == 0x8) {
                deleteFile(this->getSyncDirPath()+string(ent->d_name));
            }
        }
        closedir(dir);
    } 
	cout << "Deleted all files." << endl;
	MessageData packet = make_packet(TYPE_LIST_SERVER, 1, 1, -1, "list_server");
	socket->send(&packet);
	this->fileRecords = this->receiveFileList(this->getSocket());
	for(FileRecord record : this->fileRecords){
		MessageData request = make_packet(TYPE_REQUEST_DOWNLOAD, 1 , 1, -1, record.filename);
		this->socket->send(&request);
		MessageData *data = this->socket->receive(TIMEOUT_OFF);
		if(data->type == TYPE_SEND_FILE) {
			this->receiveFile(this->socket, record.filename, this->getSyncDirPath());
		}
	}
	this->printFileList(this->fileRecords);
	cout << "Received all files." << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2138, %rsp           # imm = 0x2138
movq %rdi, %rbx
callq 0x4ab0
movq %rbx, -0x38(%rbp)
leaq 0x50(%rbx), %rsi
leaq -0x2160(%rbp), %r15
movq %r15, %rdi
movq %rsi, -0x40(%rbp)
callq 0x33d0
movq (%r15), %rdi
callq 0x3450
movq %rax, %r14
movq %r15, %rdi
callq 0x3170
testq %r14, %r14
je 0x3c7a
leaq -0x2160(%rbp), %rbx
leaq -0x1188(%rbp), %r12
leaq -0xc8(%rbp), %r13
movq %r14, %rdi
callq 0x3470
testq %rax, %rax
je 0x3c72
movq %rax, %r15
cmpb $0x8, 0x12(%rax)
jne 0x3c06
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq 0x33d0
addq $0x13, %r15
movq %r12, %rdi
movq %r15, %rsi
leaq -0x1b0(%rbp), %rdx
callq 0x3130
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x51aa
movq -0x38(%rbp), %rdi
movq %r13, %rsi
callq 0x6b96
movq %r13, %rdi
callq 0x3170
movq %r12, %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3170
jmp 0x3c06
movq %r14, %rdi
callq 0x34c0
movq 0xd347(%rip), %rdi      # 0x10fc8
leaq 0x8489(%rip), %rsi      # 0xc111
callq 0x3310
movq %rax, %rdi
callq 0x31c0
leaq 0x8488(%rip), %r9       # 0xc124
leaq -0x2160(%rbp), %r14
pushq $0x6
popq %rsi
pushq $0x1
popq %rcx
pushq $-0x1
popq %r8
movq %r14, %rdi
movl %ecx, %edx
callq 0x57f0
movq -0x38(%rbp), %rbx
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0xb850
movq 0x40(%rbx), %rdx
leaq -0x1188(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x66b4
leaq 0xc0(%rbx), %rdi
movq %rdi, -0x48(%rbp)
movq %r14, %rsi
callq 0x5732
movq %r14, %rdi
callq 0x5508
movq 0xc0(%rbx), %r14
movq 0xc8(%rbx), %rax
movq %rax, -0x50(%rbp)
leaq -0xa8(%rbp), %r13
leaq -0x88(%rbp), %rbx
cmpq -0x50(%rbp), %r14
je 0x3dd4
movl $0xe8, %edx
leaq -0x1b0(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x3280
leaq -0x1188(%rbp), %r15
movq %r15, %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rcx
movl %ecx, %edx
pushq $-0x1
popq %r8
movq %r12, %r9
callq 0x57f0
movq -0x38(%rbp), %r12
movq 0x40(%r12), %rdi
movq %r15, %rsi
callq 0xb850
movq 0x40(%r12), %rdi
xorl %esi, %esi
callq 0xb9d4
cmpl $0x3, (%rax)
jne 0x3dc8
movq -0x38(%rbp), %rax
movq 0x40(%rax), %r15
movq %r13, %rdi
leaq -0x1b0(%rbp), %rsi
leaq -0x29(%rbp), %rdx
callq 0x3130
movq %rbx, %r12
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq 0x33d0
movq -0x38(%rbp), %rdi
movq %r15, %rsi
movq %r13, %r15
movq %r13, %rdx
movq %r12, %rcx
callq 0x5a7a
movq %r12, %rdi
callq 0x3170
movq %r15, %rdi
callq 0x3170
addq $0xe8, %r14
jmp 0x3d18
leaq -0x68(%rbp), %r14
movq %r14, %rdi
movq -0x48(%rbp), %rsi
callq 0x514a
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x6742
leaq -0x68(%rbp), %rdi
callq 0x5508
movq 0xd1c8(%rip), %rdi      # 0x10fc8
leaq 0x8329(%rip), %rsi      # 0xc130
callq 0x3310
movq %rax, %rdi
callq 0x31c0
addq $0x2138, %rsp           # imm = 0x2138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x5508
jmp 0x3e87
movq %rax, %rbx
jmp 0x3e4d
movq %rax, %rbx
jmp 0x3e59
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x3170
leaq -0x1188(%rbp), %rdi
callq 0x3170
leaq -0x2160(%rbp), %rdi
jmp 0x3e82
movq %rax, %rbx
jmp 0x3e7b
movq %rax, %rbx
jmp 0x3e87
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x3170
leaq -0xa8(%rbp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3540
nop