Subject: Re: directory listings
From: [email-masked] (Sune Falck)

17 Mar 1998 21:30:37 -0800
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
To: "Scott Mueller" <[email-masked]>, <[email-masked]>

----------
> From: Scott Mueller <[email-masked]>
> To: [email-masked]
> 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
"[email-masked]" with one line of text: "help".