private void openAndCheckFile() throws IOException {
        File file = new File(path);
        if (file.exists()) {
            if (!file.isFile()) {
                throw new IOException(path + " is not a file");
            }
            capacityFact = file.length();
            if (!recoveryMode && capacityFact != capacityWant) {
                // the file exists but not the same size as requested
                throw new WALCapacityMismatchException(path, capacityWant, capacityFact);
            }
        } else {
            // the file does not exist
            if (recoveryMode) {
                throw new WALNotInitializedException("try to open an uninitialized WAL in recovery mode: file not exists. path: " + path);
            }
            WALUtil.createFile(path, capacityWant);
            capacityFact = capacityWant;
        }
    }
Create the file and set length if not exists, and check the file size if exists.
s3stream/src/main/java/com/automq/stream/s3/wal/util/WALBlockDeviceChannel.java