follow lib naming convention working implementation for user and group

2007-12-09  Hans Breuer  <hans@breuer.org>

	* 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
This commit is contained in:
Hans Breuer 2007-12-09 22:10:40 +00:00 committed by Hans Breuer
parent 29ca2e26b0
commit d527cd5d9b
3 changed files with 78 additions and 28 deletions

View File

@ -1,3 +1,9 @@
2007-12-09 Hans Breuer <hans@breuer.org>
* 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 <awalton@svn.gnome.org> 2007-12-09 A. Walton <awalton@svn.gnome.org>
* gdesktopappinfo.c: * gdesktopappinfo.c:

View File

@ -1266,14 +1266,14 @@ get_thumbnail_attributes (const char *path,
} }
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
void static void
win32_get_file_user_info (const gchar* filename, win32_get_file_user_info (const gchar* filename,
gchar **group_name, gchar **group_name,
gchar **user_name, gchar **user_name,
gchar **real_name) gchar **real_name)
{ {
PSECURITY_DESCRIPTOR psd = NULL; 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); wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
if ((GetFileSecurityW (wfilename, if ((GetFileSecurityW (wfilename,
@ -1283,32 +1283,75 @@ win32_get_file_user_info (const gchar* filename,
&sd_size) || (ERROR_INSUFFICIENT_BUFFER == GetLastError())) && &sd_size) || (ERROR_INSUFFICIENT_BUFFER == GetLastError())) &&
(psd = g_try_malloc (sd_size)) != NULL && (psd = g_try_malloc (sd_size)) != NULL &&
GetFileSecurityW (wfilename, GetFileSecurityW (wfilename,
GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION, GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION,
psd, psd,
sd_size, sd_size,
&sd_size)) &sd_size))
{ {
PSID psid = 0; PSID psid = 0;
SID_NAME_USE name_use; /* don't care? */ BOOL defaulted;
char *name = NULL; SID_NAME_USE name_use = 0; /* don't care? */
DWORD name_len = 0; wchar_t *name = NULL;
if (user_name && wchar_t *domain = NULL;
GetSecurityDescriptorOwner (psd, &psid, NULL) && DWORD name_len = 0;
(LookupAccountSid (NULL, /* local machine */ DWORD domain_len = 0;
psid, /* get the user name */
name, &name_len, do {
NULL, NULL, /* no domain info yet */ if (!user_name)
&name_use) || (ERROR_INSUFFICIENT_BUFFER == GetLastError())) && break;
(name = g_try_malloc (name_len)) != NULL && if (!GetSecurityDescriptorOwner (psd, &psid, &defaulted))
LookupAccountSid (NULL, /* local machine */ break;
psid, if (!LookupAccountSidW (NULL, /* local machine */
name, &name_len, psid,
NULL, NULL, /* no domain info yet */ name, &name_len,
&name_use)) domain, &domain_len, /* no domain info yet */
{ &name_use) && (ERROR_INSUFFICIENT_BUFFER != GetLastError()))
*user_name = name; break;
} name = g_try_malloc (name_len*sizeof(wchar_t));
g_free (psd); 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); g_free (wfilename);
} }

View File

@ -251,7 +251,8 @@ libgio-$(PKG_VER).dll : $(OBJECTS) $(PACKAGE).def
$(CC) $(CFLAGS) -LD -Felibgio-$(PKG_VER).dll $(OBJECTS) \ $(CC) $(CFLAGS) -LD -Felibgio-$(PKG_VER).dll $(OBJECTS) \
..\glib\glib-2.0.lib ..\gobject\gobject-2.0.lib ..\gmodule\gmodule-2.0.lib \ ..\glib\glib-2.0.lib ..\gobject\gobject-2.0.lib ..\gmodule\gmodule-2.0.lib \
$(INTL_LIBS) \ $(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 : .c.obj :
$(CC) $(CFLAGS) -c $(PKG_CFLAGS) $< $(CC) $(CFLAGS) -c $(PKG_CFLAGS) $<