Boyd, Todd M.
2008-06-04 20:56:09 UTC
First off, I apologize if the answer to my question is an "obvious" one.
I have spent an exorbitant amount of time searching through mailing list
archives, forums, FAQs, help files, and websites to no avail.
I have written a program in C and compiled it on my VirtualPC, which is
running Debian. In this program, I am using the "scandir" function and
the "dirent" structure(s) it returns. The "d_type" member of the
"dirent" structure is where I hit a discrepancy between Windows and
Linux. This member is apparently not present in Windows' GNU version of
"dirent.h".
I have seen some confusing posts elsewhere about using the Microsoft
Visual C header file "direct.h" (albeit modified) to accomplish the
cross-over, but I don't even know where to begin as far as what needs to
be removed from the MSVC header in order for it to properly compile
under MinGW's "gcc" compiler. So, I pose two questions:
1.) Is the MSVC "hack" the best (or most viable) solution to my
problem, or is there a pre-configured "dirent.h"/"direct.h" out there
that will accomplish the cross-over?
2.) If the MSVC "hack" is the way to go, what needs to be stripped
from the file (and what other steps need to be taken) for it to compile
properly with MinGW's "gcc"?
Any help you can offer would be greatly appreciated! Again-I have
already written the program. It works (in Linux)... like a charm. I
merely want to port it over to Windows without making any major
modifications to the source, seeing as how the only discrepancy between
the two platforms (with regard to my code) is the absence of
"dirent->d_type" to determine if the "file" in question is actually a
directory. I understand that there are other ways to traverse
directories in Windows, but all of them I have discovered so far would
require a complete overhaul of most of the code involved in my project.
Thanks!
Todd Boyd
Web Programmer
P.S. - For those of you who are curious... the program is a crawler that
will traverse directories through recursive descension and search
specified file extensions for regex matches in their contents.
I have spent an exorbitant amount of time searching through mailing list
archives, forums, FAQs, help files, and websites to no avail.
I have written a program in C and compiled it on my VirtualPC, which is
running Debian. In this program, I am using the "scandir" function and
the "dirent" structure(s) it returns. The "d_type" member of the
"dirent" structure is where I hit a discrepancy between Windows and
Linux. This member is apparently not present in Windows' GNU version of
"dirent.h".
I have seen some confusing posts elsewhere about using the Microsoft
Visual C header file "direct.h" (albeit modified) to accomplish the
cross-over, but I don't even know where to begin as far as what needs to
be removed from the MSVC header in order for it to properly compile
under MinGW's "gcc" compiler. So, I pose two questions:
1.) Is the MSVC "hack" the best (or most viable) solution to my
problem, or is there a pre-configured "dirent.h"/"direct.h" out there
that will accomplish the cross-over?
2.) If the MSVC "hack" is the way to go, what needs to be stripped
from the file (and what other steps need to be taken) for it to compile
properly with MinGW's "gcc"?
Any help you can offer would be greatly appreciated! Again-I have
already written the program. It works (in Linux)... like a charm. I
merely want to port it over to Windows without making any major
modifications to the source, seeing as how the only discrepancy between
the two platforms (with regard to my code) is the absence of
"dirent->d_type" to determine if the "file" in question is actually a
directory. I understand that there are other ways to traverse
directories in Windows, but all of them I have discovered so far would
require a complete overhaul of most of the code involved in my project.
Thanks!
Todd Boyd
Web Programmer
P.S. - For those of you who are curious... the program is a crawler that
will traverse directories through recursive descension and search
specified file extensions for regex matches in their contents.