19 "VOLK_NOACTION: No action or change of state occurred.",
20 "VOLK_NORESULT: No result.",
21 "VOLK_END: End of the loop reached.",
22 "VOLK_CONFLICT: A conflict prevented a resource from being updated.",
34 "VOLK_ERROR: Runtime error.",
35 "VOLK_PARSE_ERR: Error parsing input.",
36 "VOLK_VALUE_ERR: Invalid input.",
37 "VOLK_TXN_ERR: MDB transaction error.",
38 "VOLK_DB_ERR: Database error.",
39 "VOLK_NOT_IMPL_ERR: Feature is not implemented.",
40 "VOLK_IO_ERR: Input/Output error.",
41 "VOLK_MEM_ERR: Memory error.",
42 "VOLK_CONFLICT_ERR: A resource conflict interrupted the operation.",
43 "VOLK_ENV_ERR: Environment not initialized. Did you call VOLK_init()?",
52 char *path =
strdup (_path);
56 for (p = path + strlen (path) - 1; p > path; p--)
57 if (*p ==
'/') *p =
'\0';
64 for (p = path + 1; *p; p++) {
69 if (mkdir (path, mode) != 0 && errno != EEXIST)
goto finally;
74 if (mkdir (path, mode) != 0) {
75 if (errno != EEXIST) rc = errno;
94 size_t len = strlen (src);
95 if (len > max) len = max;
98 dup = malloc (len + 1);
100 memcpy (dup, src, len);
112 dup = malloc (strlen (src) + 1);
113 if (dup) strcpy(dup, src);
129 struct stat stat_path, stat_entry;
130 struct dirent *entry;
133 int rc = stat(path, &stat_path);
137 if (S_ISDIR(stat_path.st_mode) == 0) {
138 log_error (
"%s: %s\n",
"Is not a directory", path);
143 if ((dir = opendir(path)) == NULL) {
144 log_error (
"%s: %s\n",
"Can`t open directory", path);
149 path_len = strlen(path);
152 while ((entry = readdir(dir)) != NULL) {
155 if (!strcmp(entry->d_name,
".") || !strcmp(entry->d_name,
".."))
160 path_len + 1 + strlen(entry->d_name) + 1,
sizeof(
char));
161 strcpy(full_path, path);
162 strcat(full_path,
"/");
163 strcat(full_path, entry->d_name);
166 stat(full_path, &stat_entry);
169 if (S_ISDIR(stat_entry.st_mode) != 0) {
176 if (unlink(full_path) == 0)
177 log_debug (
"Removed a file:\t%s\n", full_path);
179 log_error (
"Can't remove a file:\t%s\n", full_path);
184 if (rmdir(path) == 0)
185 log_debug (
"Removed a directory:\t%s\n", path);
187 log_error (
"Can't remove a directory:\t%s\n", path);
204 return mdb_strerror (rc);
210int utf8_encode (
const uint32_t utf,
unsigned char *out);
char * err_msg[]
error messages.
bool VOLK_env_is_init
Whether the environment is initialized.
char * warning_msg[]
Warning messages.
char * strdup(const char *src)
Replacement for GNU strdup.
int utf8_encode(const uint32_t utf, unsigned char *out)
Encode a code point using UTF-8.
VOLK_rc rm_r(const char *path)
Remove a directory recursively (POSIX compatible).
#define VOLK_MIN_ERROR
Minimum error value.
char * strndup(const char *src, size_t max)
Replacement for GNU strndup.
#define VOLK_MIN_WARNING
First warning value.
VOLK_rc mkdir_p(const char *_path, mode_t mode)
Make recursive directories.
#define VOLK_OK
Generic success return code.
#define VOLK_NOACTION
No action taken.
#define VOLK_IO_ERR
I/O error.
const char * VOLK_strerror(VOLK_rc rc)
Return an error message for a return code.