Skip to content

Commit

Permalink
[πŸš‚] Fix createDirectory documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ScribbleTAS committed Dec 18, 2024
1 parent 6888f41 commit 7daec20
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,24 @@ protected AbstractDataFile(Path file, String name, String comment) {

/**
* Creates the directory for the file if it doesn't exist
* @param file The file to create the directory for
* @param directory The file to create the directory for
*/
public static void createDirectory(Path file) throws IOException {
// Test if tasfiles is a file but named "tasfiles". If yes, delete that and replace with a directory
if (Files.exists(file) && !Files.isDirectory(file)) {
Files.delete(file);
public static void createDirectory(Path directory) throws IOException {
/*
* Test if the directory is a file,
* but named like the target directory.
*
* For example, naming a file "tasfiles" and
* putting it in the saves folder will succeed the "Files.exists" check,
* but fail everywhere, where a directory is required...
*
* If this is the case, delete the file and create a directory instead.
*/
if (Files.exists(directory) && !Files.isDirectory(directory)) {
Files.delete(directory);
}

Files.createDirectories(file);
Files.createDirectories(directory);
}

public void load() {
Expand Down

0 comments on commit 7daec20

Please sign in to comment.