Mail Archives: cygwin/1998/03/17/21:30:37
----------
> From: Scott Mueller <umuels00 AT mcl DOT ucsb DOT edu>
> To: gnu-win32 AT cygnus DOT com
> Subject: directory listings
> Date: den 14 mars 1998 01:00
>
> I can't believe how incredibly frustrating it has been to simply display
> a list of files in the current directory with a c program. I wrote code
The following example compiles in MSVC 4.2 and in gcc 2.8.1 mingw32
without any problems.
compile with "cl find.c" in MSVC or "cc -o find.exe find.c" with gcc.
D:\tmp>cc -o find.exe find.c
D:\tmp>find
File name : .
File name : ..
File name : adder.c
File name : adder.o
File name : adder.obj
File name : atest-g.exe
File name : atest.adb
File name : atest.ali
File name : atest.o
File name : btest.adb
File name : btest.ali
find.c
------
#include <stdio.h>
#include <stdlib.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
int main (int argc, char ** argv)
{
HANDLE Find_Handle;
WIN32_FIND_DATA Find_Info;
Find_Handle = FindFirstFile ("*.*", &Find_Info);
if (Find_Handle == INVALID_HANDLE_VALUE) {
fprintf (stderr, "No files or other error !\n");
return EXIT_FAILURE;
}
else {
do {
fprintf (stdout, "File name : %s\n", Find_Info.cFileName);
} while (FindNextFile (Find_Handle, &Find_Info));
FindClose (Find_Handle);
}
return EXIT_SUCCESS;
}
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -