mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 22:16:16 +01:00
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:
parent
29ca2e26b0
commit
d527cd5d9b
@ -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>
|
||||
|
||||
* gdesktopappinfo.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))
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
@ -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) $<
|
||||
|
Loading…
Reference in New Issue
Block a user