private void prepareFile(File file, String name, FileKind kind) throws IOException {
        if (roundOver) {
            bark.aptWarning("NoNewFilesAfterRound", file.toString());
            throw new IOException();
        }

        if (filesCreated.contains(file)) {
            bark.aptWarning("FileReopening", file.toString());
            throw new IOException();
        } else {
            if (file.exists()) {
                file.delete();
            } else {
                File parent = file.getParentFile();
                if (parent != null && !parent.exists()) {
                    if(!parent.mkdirs()) {
                        bark.aptWarning("BadParentDirectory", file.toString());
                        throw new IOException();
                    }
                }
            }

            kind.register(file, name, this);
            filesCreated.add(file);
        }
    }