2#include "region_impl.h"
10 "Invalid opts.version %d. Current version is %d. Make sure to set opts.version correctly or update the library.",
16 if (src->
dims > CLOD_REGION_DIMENSIONS_MAX) {
18 "Invalid opts.dims %d. Must be <= %d.", src->
dims,
19 CLOD_REGION_DIMENSIONS_MAX);
27 if (src->
mode != CLOD_REGION_MODE_RDWR && src->
mode != CLOD_REGION_MODE_RDONLY) {
29 "Invalid opts.mode %d. Must be CLOD_REGION_MODE_RDWR or CLOD_REGION_MODE_RDONLY.",
34 dst->
mode = CLOD_REGION_MODE_RDWR;
40 "Invalid opts.unix_fd %d. Must be >= 0.",
51 if (memchr(src->
prefix,
'.', CLOD_REGION_PREFIX_MAX) !=
nullptr) {
53 "Invalid opts.prefix %s. Must not contain a '.' character.",
56 strncpy(dst->
prefix, src->
prefix, CLOD_REGION_PREFIX_MAX);
57 dst->
prefix[CLOD_REGION_PREFIX_MAX] =
'\0';
59 strncpy(dst->
prefix,
"region", CLOD_REGION_PREFIX_MAX + 1);
64 dst->
region_ext[CLOD_REGION_EXTENSION_MAX] =
'\0';
66 strncpy(dst->
region_ext,
"mcr", CLOD_REGION_EXTENSION_MAX + 1);
71 dst->
chunk_ext[CLOD_REGION_EXTENSION_MAX] =
'\0';
73 strncpy(dst->
chunk_ext,
"mcc", CLOD_REGION_EXTENSION_MAX + 1);
79 "Invalid opts.compression %d. Either the required compression library has been intentionally disabled, or the compression mode is invalid.",
83 }
else if (is_vanilla_compatible(dst)) {
86 "libdeflate has been disabled, but it is required to compress/decompress minecraft-compatible region files.");
100 if (!r)
return nullptr;
103 if (!read_opts(&r->opts, opts)) {
109 auto const res = dir_open(&r->d, path, &r->opts);
111 mutex_destroy(&r->mtx);
122 if (r->inside != 0) {
127 mutex_destroy(&r->mtx);
128 auto const dir_res = dir_close(r->d);
129 auto const fc_res = file_cache_destroy(r);
bool clod_compression_support(enum clod_compression_method method)
#define CLOD_REGION_VERSION
struct clod_region * clod_region_open(const char *path, const struct clod_region_opts *opts)
enum clod_region_result clod_region_close(struct clod_region *r)
@ CLOD_REGION_INVALID_USAGE
enum clod_compression_method compression