Re: opendir() failes with trailing \

Tor Lillqvist <[email protected]>
Newsgroups gmane.comp.video.gimp.windows.devel
Message-ID <[email protected]>
David L Norris writes:
 > stat() on Win32 doesn't work like one might expect; I'd dare say it's
 > broken.

(Technically, you mean stat() in msvcrt.dll, which is just one C
runtime library for Win32, but indeed the most "official" one, and the
one GIMP use.)

Agree. But as there is no chance of fixing all the msvcrt.dll copies
out there, so this is just something that has to be coded around,
sigh.

From your test it seems that the stat() argument should not have a
trailing backslash *except* if it is the root directory on a drive or
share, when there *must* be a trailing backslash. Sickening.

I guess a workaround to this trailing-backslash-on-directory-ok-or-not
madness could be added to g_file_test() which is what GLib-using
programs should be using anyway instead of stat() for testing file
existence, path being a directory, etc.

Still, opendir() works regardless whether there is a trailing slash or
not for me, on Windows 2000. What OS do you run, Cameron?

(That is the opendir() in mingw's own small aux library, libmingw32. A
copy of that is provided for MSVC folks in the dirent.zip on the
gimpwin website. Until about a year ago GLib used to have its own
(different) dirent emulation for Win32 (g_win32_opendir etc), but
surely such an old GLib isn't what you are using Cameron?)

--tml
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.