mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-10-06 07:59:12 +00:00
Add platform support for getting user home directory
This commit is contained in:
parent
5f60982686
commit
a0d448304d
|
@ -26,6 +26,9 @@
|
|||
#include <gdk/gdkquartz.h>
|
||||
#include <gio/gunixinputstream.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
gboolean
|
||||
gitg_platform_support_use_native_window_controls (GdkDisplay *display)
|
||||
{
|
||||
|
@ -190,4 +193,29 @@ gitg_platform_support_get_data_dir (void)
|
|||
return g_strdup (GITG_DATADIR);
|
||||
}
|
||||
|
||||
gchar *
|
||||
gitg_platform_support_get_user_home_dir (const gchar *name)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
name = g_get_user_name ();
|
||||
}
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pwd = getpwnam (name);
|
||||
|
||||
if (pwd == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_strdup (pwd->pw_dir);
|
||||
}
|
||||
|
||||
// ex:ts=4 noet
|
||||
|
|
|
@ -100,4 +100,11 @@ gitg_platform_support_get_data_dir (void)
|
|||
return data_dir;
|
||||
}
|
||||
|
||||
gchar *
|
||||
gitg_platform_support_get_user_home_dir (const gchar *name)
|
||||
{
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ex:ts=4 noet
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
#include <gio/gunixinputstream.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
gboolean
|
||||
gitg_platform_support_use_native_window_controls (GdkDisplay *display)
|
||||
{
|
||||
|
@ -117,4 +120,29 @@ gitg_platform_support_get_data_dir (void)
|
|||
return g_strdup (GITG_DATADIR);
|
||||
}
|
||||
|
||||
gchar *
|
||||
gitg_platform_support_get_user_home_dir (const gchar *name)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
name = g_get_user_name ();
|
||||
}
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pwd = getpwnam (name);
|
||||
|
||||
if (pwd == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_strdup (pwd->pw_dir);
|
||||
}
|
||||
|
||||
// ex:ts=4 noet
|
||||
|
|
|
@ -50,6 +50,8 @@ gchar *gitg_platform_support_get_locale_dir (void);
|
|||
|
||||
gchar *gitg_platform_support_get_data_dir (void);
|
||||
|
||||
gchar *gitg_platform_support_get_user_home_dir (const gchar *name);
|
||||
|
||||
#endif /* __GITG_PLATFORM_SUPPORT_H__ */
|
||||
|
||||
// ex:ts=4 noet
|
||||
|
|
|
@ -18,5 +18,6 @@ namespace Gitg
|
|||
public static string get_lib_dir();
|
||||
public static string get_locale_dir();
|
||||
public static string get_data_dir();
|
||||
public static string? get_user_home_dir(string? user = null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue