Explicitly creates a new, empty HDF5 file.
Details
This function is a simple wrapper around h5_create_group(file, "/").
Its main purpose is to allow for explicit file creation in code.
Note that calling this function is almost always unnecessary, as all
h5lite writing functions (like h5_write() or
h5_create_group()) will automatically create
the file if it does not exist.
It is provided as a convenience for users who prefer to explicitly create a file before writing data to it.
File Handling
If
filedoes not exist, it will be created as a new, empty HDF5 file.If
filealready exists and is a valid HDF5 file, this function does nothing and returns successfully.If
fileexists but is not a valid HDF5 file (e.g., a text file), an error will be thrown and the file will not be modified.
Examples
file <- tempfile(fileext = ".h5")
# Explicitly create the file
h5_create_file(file)
if (file.exists(file)) {
message("File created successfully.")
}
#> File created successfully.
unlink(file)
