Flush
[mono.git] / support / macros.c
index 27d7065014a694afd8f7a5fefc39063b5eaa9010..c763a7ca2f8719d442cda74e017ee846fedf4fa8 100644 (file)
@@ -4,6 +4,9 @@
 #include <unistd.h>
 #include <pwd.h>
 #include <grp.h>
+#include <errno.h>
+#include <dirent.h>
+#include <string.h>
 
 int wifexited (int status)
 {
@@ -79,11 +82,16 @@ int helper_Mono_Posix_Stat(char *filename, int dereference,
 char *helper_Mono_Posix_GetUserName(int uid) {
        struct passwd *p = getpwuid(uid);
        if (p == NULL) return NULL;
-       return p->pw_name;
+       return strdup (p->pw_name);
 }
 char *helper_Mono_Posix_GetGroupName(int gid) {
        struct group *p = getgrgid(gid);
        if (p == NULL) return NULL;
-       return p->gr_name;
+       return strdup (p->gr_name);
 }
 
+char *helper_Mono_Posix_readdir(DIR *dir) {
+       struct dirent* e = readdir(dir);
+       if (e == NULL) return NULL;
+       return strdup (e->d_name);
+}