chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
catalog: open up catalog internals
[elogind.git]
/
src
/
shared
/
util.c
diff --git
a/src/shared/util.c
b/src/shared/util.c
index 8fa01fa8a49609baf640ef850da891ac19dfcb85..2241b79859ff16233f4a33e7f66aea13efb11464 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-59,6
+59,7
@@
#include <limits.h>
#include <langinfo.h>
#include <locale.h>
#include <limits.h>
#include <langinfo.h>
#include <locale.h>
+#include <libgen.h>
#include "macro.h"
#include "util.h"
#include "macro.h"
#include "util.h"
@@
-2356,6
+2357,24
@@
int dir_is_empty(const char *path) {
}
}
}
}
+char* dirname_malloc(const char *path) {
+ char *d, *dir, *dir2;
+
+ d = strdup(path);
+ if (!d)
+ return NULL;
+ dir = dirname(d);
+ assert(dir);
+
+ if (dir != d) {
+ dir2 = strdup(dir);
+ free(d);
+ return dir2;
+ }
+
+ return dir;
+}
+
unsigned long long random_ull(void) {
_cleanup_close_ int fd;
uint64_t ull;
unsigned long long random_ull(void) {
_cleanup_close_ int fd;
uint64_t ull;