Re: testglib and user-dirs.dirs



On Mandag 31. desember 2007, Matthias Clasen wrote:
> On Dec 31, 2007 12:39 PM, Matthias Clasen <matthias clasen gmail com> wrote:
> > On Dec 31, 2007 12:36 PM, Asbjørn <asbgpe online no> wrote:
> > > code:
> > >  uddesktop = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
> > >  g_assert (uddesktop != NULL);
> > >  udddocs = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
> > >   g_assert (udddocs != NULL);
> > >   uddpubshare = g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE);
> > >   g_assert (uddpubshare != NULL);
> >
> > The test is not correct. GLib only guarantees that
>
> Sorry abouty that...
>
> what I meant to say is that GLib only guarantees the desktop directory
> to be non-NULL, the others may well be NULL.

Ok. 
The first fail will at G_USER_DIRECTORY_DOCUMENTS.

Then the code could be like this:
.....
if (file_exists("HOME/.config/user-dirs.dirs"))
{
     udddocs = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
     g_assert (udddocs != NULL);
     uddpubshare = g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE);
     g_assert (uddpubshare != NULL);
}
...



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]