/*
 * Deletes the file called file. Returns true if successful, false otherwise. 
 * A file may be removed regardless of whether it is open or closed, and 
 * Removing an open file does not close it. See Removing an Open File, for
 * Details.
 *
 * Authored by Alex Stratford
 */


#include "system_calls.h"
#include "threads/interrupt.h" // Dependency for intr_frame struct
#include "filesys/file.h" // Dependency for and file struct
#include "filesys/filesys.h" // Dependency for filesys_remove

void syscall_remove(struct intr_frame *f) {
	// pop off first int argument from interrupt frame
	char* file_name = (void*)*((int*)f->esp + 1);
	// Described in filesys.h, opens the file
	if (filesys_remove(file_name) == false) { // Checking if file is empty or non-existent
		f->eax = false; // Returning a failure state
		return;
	}
	f->eax = true;
}