So I have a method to delete a file from my file system but I wanted to write another method that could restore the previously deleted file. the only problem is I don't know how I would start writing it. My code for the delete the file is:
public int unlink( String name ) { for(int i = 0; i < C.DIR_ENTRIES; i++) { Directory de = readEntryDir(i); if (de.getName().equals(name)) { de.setName(""); writeEntryDir(i,de); int curBlock = de.getStart(); int nextBlock = 0; while(readEntryFAT(curBlock) != C.END) { nextBlock = readEntryFAT(curBlock); writeEntryFAT(curBlock, C.FREE); curBlock = nextBlock; } writeEntryFAT(curBlock, C.FREE); } } return C.OK; }
Any help would be appreciated