Command Prompt for Windows




getfile, _wgetfile, _tgetfile

BOOL getfile(int index, struct ffblk *pff);
BOOL _wgetfile(int index, struct _wffblk *pff);
BOOL _tgetfile(int index, struct _tffblk *pff);

Retrieve a DOS file control block structure from the File Table.

Parameter Description
index Specifies which ffblk to retrieve from the File Table. Entries in the File Table start from an index of 0.
pff Address of a DOS file control block structure (defined in WOIO.H) :-
struct  ffblk   {
  long            ff_reserved;	/* reserved */
  long            ff_fsize;	/* file size */
  unsigned long   ff_attrib;	/* file attribute */
  unsigned short  ff_ftime;	/* file time */
  unsigned short  ff_fdate;	/* file date */
  char            ff_name[256];	/* file name */
};
or
struct  _wffblk   {
  long            ff_reserved;	/* reserved */
  long            ff_fsize;	/* file size */
  unsigned long   ff_attrib;	/* file attribute */
  unsigned short  ff_ftime;	/* file time */
  unsigned short  ff_fdate;	/* file date */
  wchar_t         ff_name[256];	/* file name */
};

Returns

On success, it returns a non-zero value and the file control block structure is filled. On error zero is returned.

Comments

Use the fillfile() to fill the File Table before using getfile().

See Also

fillfile, getfilepath, getfilename

Example

#include "woio.h"
#include <dir.h>
 
/* Display a file listing */

int dir(char *path)
{
    int i, n;
    struct ffblk ffblk;

    printf("%cDirectory of %s\n\n", COL_HIGHTEXT, path);

    if ((n = fillfile(path, 0)) == 0) {
        perror("No files found");
        return 1;
    }

    for (i = 0;i < n;i++) {

        if (getfile(i, &ffblk) == FALSE) {
            perror("Bad index");
            return 1;
        }

        printf(" %c%-13s%c%9ld\n",
            COL_FILENAME, ffblk.ff_name,
            COL_NUMBER, ffblk.ff_fsize); /* display file names */

    }

    return 0;      /* all done */
}

int main(void)
{
    char *path;
    int ret;

    if (argc() > 1) {  /* check number of arguments */
        perror("Too many or few arguments");
        return 1;
    }

    screen(BUFFERED);  /* buffered screen output */

    if ((path = argpath(argc())) == NULL) {
        perror("Path or file not found");
        return 1;
    }

    ret = dir(path);    

    screen(UNBUFFERED); /* flush output */

    return ret;     /* error level */
}