Next part is reimplementing of what I call "standard directories API".

g_get_system_config_dirs
g_get_user_config_dir
g_get_home_dir
g_get_user_special_dir(G_USER_DIRECTORY_MUSIC)

Windows part looks easy there are plenty of standard functions with 
different levels of obsolescence for that.

For Unix version I need some assistance.

g_get_home_dir() works differently depending on GLib version.
Newer GLib versions check $HOME first
and if it's empty use getpwnam_r() to obtain home directory for 
currently user.
Old versions go straight into using getpwnam_r().
What approach should we use?

Second issue: GLib uses two flavors of getpwnam_r()
(guarded by HAVE_POSIX_GETPWUID_R and HAVE_NONPOSIX_GETPWUID_R in the code).
What should we do with that?

https://developer.gnome.org/glib/2.38/glib-Miscellaneous-Utility-Functions.html#g-get-home-dir
https://git.gnome.org/browse/glib/tree/glib/gutils.c

For reimplementing g_get_user_special_dir(G_USER_DIRECTORY_MUSIC) I 
think we need to parse "user-dirs.dirs" file. I didn't any reference 
documentation on this. However I've found the source 
http://cgit.freedesktop.org/xdg/xdg-user-dirs/tree/xdg-user-dir-lookup.c
I think this could be reused as-is, it does not look very efficient, but 
this function is going to be called at most once after all.
One more question what encoding is this file supposed to have?

Bonus question:

In the MPD code AllocatedPath::FromUTF8() is called on the results of 
GLib calls, however I did not find any conversion of encoding in the 
GLib code (see gutils.c code above).
Maybe I'm missing something or maybe this is a bug.

-- 
Denis

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to