www.digitalmars.com         C & C++   DMDScript  

c++.rtl - findfirst returns NULL

reply Linus <linus linus.cx> writes:
Hi folks,
I tried the example code for the 'findfirst/findnext' functions. It
works in the DOS/DOSX memory models but built as a WIN32 console app
'findfirst' always returns NULL. As there definitely are files present,
this looks like a bug. Or did I miss something? I don't have the library
source, so can't check it myself (but like to buy the CD, maybe you can
arrange something apart from paypal ?).
Nov 14 2001
parent "Walter" <walter digitalmars.com> writes:
The address you can send a check or money order to is at:

    www.digitalmars.com/shop.html

I'll check into the findfirst problem. In the meantime, you might prefer to
go directly to the win32 API with code like:

Array *getFiles(char *c)
{
    Array *a;
    HANDLE h;
    file_t fileinfo;

    a = new Array();

    h = FindFirstFileA(c,&fileinfo);
    if (h != INVALID_HANDLE_VALUE)
    {
        do
        {   file_t *f;

            // Skip "." and ".."
            if (strcmp(fileinfo.cFileName, ".") == 0 ||
                strcmp(fileinfo.cFileName, "..") == 0)
                continue;

            f = (file_t *)malloc(sizeof(file_t));
            memcpy(f, &fileinfo, sizeof(fileinfo));
            a->push(f);
        } while (FindNextFileA(h,&fileinfo) != FALSE);
        FindClose(h);
    }
    return a;
}

"Linus" <linus linus.cx> wrote in message news:3BF3195C.4C0B linus.cx...
 Hi folks,
 I tried the example code for the 'findfirst/findnext' functions. It
 works in the DOS/DOSX memory models but built as a WIN32 console app
 'findfirst' always returns NULL. As there definitely are files present,
 this looks like a bug. Or did I miss something? I don't have the library
 source, so can't check it myself (but like to buy the CD, maybe you can
 arrange something apart from paypal ?).

Nov 14 2001