| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

dir_files

#include "sfldir.h"
qbyte
dir_files (const char *path, Bool recurse)

Synopsis

Calculates the number of files in a directory and optionally all directories below that. Excludes directories from the count (thus, a directory containing only '.' and '..' contains 0 files. Returns 0 if there was an error. Excludes hidden files.

Source Code - (sfldir.c)

{
    DIRST
        dir;
    qbyte
        files = 0;
    char
        *full_dir;

    if (open dir (&dir, path))
    do
      {
        if ((dir.file_attrs & ATTR_HIDDEN) != 0)
            ;   /*  Do nothing                                               */
        else
        if (recurse
        && (dir.file_attrs & ATTR_SUBDIR) != 0)
          {
            full_dir = locate path (path, dir.file_name);
            files += dir files (full_dir, TRUE);
            mem_free (full_dir);
          }
        else
            files++;
      }
    while (read dir (&dir));
    close dir (&dir);
    return (files);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation