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 stat(path, &stat_path);
136 if (S_ISDIR(stat_path.st_mode) == 0) {
137 log_error (
"%s: %s\n",
"Is not directory", path);
142 if ((dir = opendir(path)) == NULL) {
143 log_error (
"%s: %s\n",
"Can`t open directory", path);
148 path_len = strlen(path);
151 while ((entry = readdir(dir)) != NULL) {
154 if (!strcmp(entry->d_name,
".") || !strcmp(entry->d_name,
".."))
159 path_len + 1 + strlen(entry->d_name) + 1,
sizeof(
char));
160 strcpy(full_path, path);
161 strcat(full_path,
"/");
162 strcat(full_path, entry->d_name);
165 stat(full_path, &stat_entry);
168 if (S_ISDIR(stat_entry.st_mode) != 0) {
175 if (unlink(full_path) == 0)
176 LOG_DEBUG (
"Removed a file:\t%s\n", full_path);
178 log_error (
"Can't remove a file:\t%s\n", full_path);
183 if (rmdir(path) == 0)
184 LOG_DEBUG (
"Removed a directory:\t%s\n", path);
186 log_error (
"Can't remove a directory:\t%s\n", path);
203 return mdb_strerror (rc);
209int 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.