// Check 2: If the file does not exist, attempt to create it
if(ret==false){
try{
ret=file.createNewFile();
}catch(IOExceptione){
// The file could not be created
thrownewFILE_CREATE_EXCEPTION();
}
}else{
ret=true;// This might be a hot fix, but technically the file already exists so would this be true or false? --?this statement is wild?
System.out.println(ChatUtil.ColoredString("File (name: ",CONSOLE_COLOR.BLUE)+ChatUtil.ColoredString(fileName,CONSOLE_COLOR.YELLOW)+ChatUtil.ColoredString(" was determined to already exist. Exiting out",CONSOLE_COLOR.BLUE));
}
returnret;
}
// DeleteFile
//
// Returns true if file is deleted, false if could not be deleted or does not exist
System.out.println(ChatUtil.ColoredString("cannot delete file ",CONSOLE_COLOR.RED)+ChatUtil.ColoredString(fileName,CONSOLE_COLOR.YELLOW)+ChatUtil.ColoredString(" because file does not exist",CONSOLE_COLOR.BLUE));
}
returnret;
}
// WriteToFile
//
// Will write or append to file (valid modes: "w" or "a") if file is available. Returns false if not
System.out.println(ChatUtil.ColoredString("Invalid mode to WriteToFile!",CONSOLE_COLOR.RED));
break;
}
file.close();
}catch(IOExceptione){
System.out.println(ChatUtil.ColoredString("Could not open file ",CONSOLE_COLOR.RED)+ChatUtil.ColoredString(fileName,CONSOLE_COLOR.YELLOW)+ChatUtil.ColoredString(" to write to it! Possibly permission issue?",CONSOLE_COLOR.RED));
}
returnret;
}
// WriteToJsonFile
//
// Will write to or append to a json file. It will search if the key exists first & update the field;
// or add a new entry. It should be noted that json objects *can* be buried inside each other. It is
// considered best (and only) practice to call the "GetJsonStringFromFile" function first from this
// class and simply iterate to what you would need and then update the entire entry alongside the
// top-level key.
//
// NOTE: THIS DOES NOT SAFE UPDATE THE KEY OBJECT. PRE-EXISTING DATA WILL BE DELETED FOREVER
System.out.println(ChatUtil.ColoredString("Failed to make directory with name: ",CONSOLE_COLOR.RED)+ChatUtil.ColoredString(dirName,CONSOLE_COLOR.YELLOW));
ret=true;/// TODO: Hack to make Setup fn be fine with prev-created files! Make Setup more robust!