From: Hans Breuer Date: Sun, 9 Dec 2007 22:10:40 +0000 (+0000) Subject: follow lib naming convention working implementation for user and group X-Git-Tag: GLIB_2_15_1~175 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d527cd5d9b8ec9c98e1a77cbe81e6fd2acd1da4b;p=platform%2Fupstream%2Fglib.git follow lib naming convention working implementation for user and group 2007-12-09 Hans Breuer * makefile.msc : follow lib naming convention * glocalfileinfo.c(win32_get_file_user_info) : working implementation for user and group name, tested with ../tests/gio-ls svn path=/trunk/; revision=6080 --- diff --git a/gio/ChangeLog b/gio/ChangeLog index 0d42765..fee454d 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,9 @@ +2007-12-09 Hans Breuer + + * makefile.msc : follow lib naming convention + * glocalfileinfo.c(win32_get_file_user_info) : working implementation + for user and group name, tested with ../tests/gio-ls + 2007-12-09 A. Walton * gdesktopappinfo.c: diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c index dac9f93..33d7727 100644 --- a/gio/glocalfileinfo.c +++ b/gio/glocalfileinfo.c @@ -1266,14 +1266,14 @@ get_thumbnail_attributes (const char *path, } #ifdef G_OS_WIN32 -void +static void win32_get_file_user_info (const gchar* filename, gchar **group_name, gchar **user_name, gchar **real_name) { PSECURITY_DESCRIPTOR psd = NULL; - DWORD sd_size = 0; /* first call calculates the size rewuired */ + DWORD sd_size = 0; /* first call calculates the size required */ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL); if ((GetFileSecurityW (wfilename, @@ -1283,32 +1283,75 @@ win32_get_file_user_info (const gchar* filename, &sd_size) || (ERROR_INSUFFICIENT_BUFFER == GetLastError())) && (psd = g_try_malloc (sd_size)) != NULL && GetFileSecurityW (wfilename, - GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION, - psd, - sd_size, - &sd_size)) - { - PSID psid = 0; - SID_NAME_USE name_use; /* don't care? */ - char *name = NULL; - DWORD name_len = 0; - if (user_name && - GetSecurityDescriptorOwner (psd, &psid, NULL) && - (LookupAccountSid (NULL, /* local machine */ - psid, - name, &name_len, - NULL, NULL, /* no domain info yet */ - &name_use) || (ERROR_INSUFFICIENT_BUFFER == GetLastError())) && - (name = g_try_malloc (name_len)) != NULL && - LookupAccountSid (NULL, /* local machine */ - psid, - name, &name_len, - NULL, NULL, /* no domain info yet */ - &name_use)) - { - *user_name = name; - } - g_free (psd); + GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION, + psd, + sd_size, + &sd_size)) + { + PSID psid = 0; + BOOL defaulted; + SID_NAME_USE name_use = 0; /* don't care? */ + wchar_t *name = NULL; + wchar_t *domain = NULL; + DWORD name_len = 0; + DWORD domain_len = 0; + /* get the user name */ + do { + if (!user_name) + break; + if (!GetSecurityDescriptorOwner (psd, &psid, &defaulted)) + break; + if (!LookupAccountSidW (NULL, /* local machine */ + psid, + name, &name_len, + domain, &domain_len, /* no domain info yet */ + &name_use) && (ERROR_INSUFFICIENT_BUFFER != GetLastError())) + break; + name = g_try_malloc (name_len*sizeof(wchar_t)); + domain = g_try_malloc (domain_len*sizeof(wchar_t)); + if (name && domain && + LookupAccountSidW (NULL, /* local machine */ + psid, + name, &name_len, + domain, &domain_len, /* no domain info yet */ + &name_use)) + { + *user_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL); + } + g_free (name); + g_free (domain); + } while (FALSE); + + /* get the group name */ + do { + if (!group_name) + break; + if (!GetSecurityDescriptorGroup (psd, &psid, &defaulted)) + break; + if (!LookupAccountSidW (NULL, /* local machine */ + psid, + name, &name_len, + domain, &domain_len, /* no domain info yet */ + &name_use) && (ERROR_INSUFFICIENT_BUFFER != GetLastError())) + break; + name = g_try_malloc (name_len*sizeof(wchar_t)); + domain = g_try_malloc (domain_len*sizeof(wchar_t)); + if (name && domain && + LookupAccountSidW (NULL, /* local machine */ + psid, + name, &name_len, + domain, &domain_len, /* no domain info yet */ + &name_use)) + { + *group_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL); + } + g_free (name); + g_free (domain); + } while (FALSE); + + /* TODO: get real name */ + + g_free (psd); } g_free (wfilename); } diff --git a/gio/makefile.msc b/gio/makefile.msc index d4e7b8d..8f546c4 100644 --- a/gio/makefile.msc +++ b/gio/makefile.msc @@ -251,7 +251,8 @@ libgio-$(PKG_VER).dll : $(OBJECTS) $(PACKAGE).def $(CC) $(CFLAGS) -LD -Felibgio-$(PKG_VER).dll $(OBJECTS) \ ..\glib\glib-2.0.lib ..\gobject\gobject-2.0.lib ..\gmodule\gmodule-2.0.lib \ $(INTL_LIBS) \ - user32.lib advapi32.lib shell32.lib wsock32.lib $(LDFLAGS) /def:$(PACKAGE).def + user32.lib advapi32.lib shell32.lib wsock32.lib $(LDFLAGS) \ + /implib:gio-2.0.lib /def:$(PACKAGE).def .c.obj : $(CC) $(CFLAGS) -c $(PKG_CFLAGS) $<