Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>class zdirectory</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
class zDirectory

Usage

    #include <dir.hpp>
    zDirectory ...;

Description

    // The constructor takes two arguments.  The first specifies a mask to
    // restrict the files included in the list, and defaulted to all.  The
    // second restricts files based on the file attribute.

        zDirectory(char *spec = "*.*", int attr = 0);

    // The interface to the zDirectory class consists of four functions
    // to "move" through the directory,  and another to give the count of
    // files in the list.  The next and prev functions have no effect if
    // they are blocked by the end or the start of the list.

        FileInfo *first()
        {
            int rv = d.start(); return rv? 0: d();
        }
        FileInfo *last()
        {
            int rv = d.end(); return rv? 0: d();
        }
        FileInfo *next()
        {
            int rv = ++d; return rv? 0: d();
        }
        FileInfo *prev()
        {
            int rv = --d; return rv? 0: d();
        }
        int count() { return _count; }

        int error() { int e = err; err = 0; return e; }

Example 

    #include <stdlib.h>
    #include <iostream.hpp>
    #include <dir.hpp>

    main()
    {
        zDirectory cd;
        FileInfo *p;

        for (p = cd.first(); p; p = cd.next())
            cout << p->name << endl;
        cout << "\n" << cd.count() << " Files in all" << endl;
        return EXIT_SUCCESS;
    }

See Also






Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson