/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <stdlib.h>

#include <dirent.h>
#include <sys/stat.h>

#define DIRSEP "\\"
#define TESTDIR "C:\\mingw"

void process(char *path)
{
   DIR *dirp;
   struct dirent *entp;
   struct stat stbuf;
   char fnm[256];
   dirp = opendir(path);
   while((entp = readdir(dirp)) != NULL)
   {
      if(entp->d_name[0]!='.')
      {
          sprintf(fnm,"%s%s%s",path,DIRSEP,entp->d_name);
          stat(fnm,&stbuf);
          if(!S_ISDIR(stbuf.st_mode))
          {
              printf("%s %d\n",fnm,stbuf.st_size);
          } else {
              process(fnm);
          }
      }
   }
   closedir(dirp);
   return;
}

int main()
{
   process(TESTDIR);
   return 0;
}
