[PATCH] r124716 - make dirent usage more portable

Hello,

Revision 124716 introduced some code to enumerate directories which
isn't quite POSIX compatible. Specifically, the 'd_namlen' entry isn't
guaranteed to be present in POSIX compatible environments [1] (for
example, on linux/glibc, the entry is 'd_reclen'). Attached patch
fixes this.

1. <dirent.h>

lldb_dirent_posix.patch (973 Bytes)

Jai ++

I am experiencing another problem in relation to this same code: the d_type is also not mentioned in the URL you site, and the build i am attempting under MinGW fails because of this.

This patch looks like a reasonable start. I may have to build onto it to make it more cross-platform friendly with windows.

++ Kirk

lldb_dirent_posix.patch (1000 Bytes)

ATT00001.htm (1.42 KB)

Hello Kirk,

Jai ++
I am experiencing another problem in relation to this same code: the d_type
is also not mentioned in the URL you site, and the build i am attempting
under MinGW fails because of this.

Indeed, d_type is a POSIX extension as well but you'll pretty much
find it on all *nix/BSD variants. I guess you're out of luck on
windows because I doubt whether mingw (or even mingw64 and cygwin)
will get proper dirent support anytime soon. I guess applications
either perform a readdir followed by a stat (so that takes care of
DT_DIR and DT_REG) or have full-blown dirent emulation code (example
msysgit) which uses windows API calls. The later approach should be
sufficient for the usage in FileSpec.cpp, even if not all file types
are supported.

This patch looks like a reasonable start. I may have to build onto it to
make it more cross-platform friendly with windows.

I could try a few hacks but I don't have access to a mingw cross
toolchain right now. It might get a bit ugly though.

Hello Jai ++

Don’t worry about the changes for DT_DIR/DT_REG … i had already planned on doing something for this using stat, and i do have a mingw toolchain set up that i’m working with.

thanks,
++ kirk