|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sfldir.h" qbyte dir_files (const char *path, Bool recurse)
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.
{
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);
}
| | << | < | > | >> |
|