Re: g_file_test()
- From: Owen Taylor <otaylor redhat com>
- To: Tim Janik <timj gtk org>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: g_file_test()
- Date: 03 Sep 2001 21:13:12 -0400
Tim Janik <timj gtk org> writes:
> On Mon, 6 Aug 2001, Tim Janik wrote:
>
> >
> > typedef enum
> > {
> > G_FILE_TEST_IS_REGULAR = 1 << 0,
> > G_FILE_TEST_IS_SYMLINK = 1 << 1,
> > G_FILE_TEST_IS_DIR = 1 << 2,
> > G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
> > G_FILE_TEST_EXISTS = 1 << 4
> > } GFileTest;
> >
> > gboolean g_file_test (const gchar *filename,
> > GFileTest test);
> >
> > having used g_file_test() in a couple places now, i have to say that:
> > 1) it definitely needs G_FILE_TEST_IS_READABLE and G_FILE_TEST_IS_WRITABLE
> > 2) it should return TRUE only if all tests succeeded.
>
> are there actually any objections/concerns not yet raised on this issue?
> if not, i'd like to fix matters ASAP.
OK, the original discussion is at:
http://mail.gnome.org/archives/gtk-devel-list/2000-October/msg00154.html
The primary concern that came up with making it all-of is that
that would conflict with the current semantics of g_file_test()
in gnome-libs, which I think is
I agree that all-of is more what I would expect, but I don't
think the any-of behavior is so ridiculous that I would be
willing to declare programs that expect it buggy. I think if
we change the behavior, we have to change the name.
(I'd think the reason why it's any-of is what you get when you
read:
g_file_test (G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK);
Yep, "test file is regular or file is symlink".)
Possibilities for an all-of name include:
g_file_test_is_all ()
g_file_test_all ()
g_file_is_all ()
g_file_is ()
I think G_FILE_TEST_IS_READABLE/IS_WRITEABLE are open to abuse, and
its pretty hard to get them exactly right, considering things like:
- read-only mounts
- Multiple groups for a user
- ACLs on AFS
- Behavior of access as root and with setuid
Basically, the only way to safely tell if you would be able
to read/write a file is to actually do it.
Does that mean we shouldn't add them? It may be that if we don't,
people will write the tests themselves and do it worse. I don't
know...
When do you see them being useful?
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]