// stat.h
// BarSSoft, 1999
#ifndef __STAT_H__
#define __STAT_H__
#include
extern pthread_cond_t condStatusChanged;
extern int finishStatusThread;
extern char currPath[200];
void* showStatus(void* arg);
#endif
#include "stat.h"
#include "filelist.h"
#include <stdio.h>
pthread_cond_t condStatusChanged;
int finishStatusThread;
char currPath[200];
#define MAX_PATH_LEN 40
void* showStatus(void* arg)
{
int i;
char s[100], *pos;
static int files = 0, dirs = 0;
static int totalFiles = 0, totalDirs = 0, oldNextItem;
pthread_mutex_lock(&lockFileList);
while (!finishStatusThread)
{
pthread_cond_wait(&condStatusChanged, &lockFileList);
if (oldNextItem > nextItem)
{
totalFiles += files;
totalDirs += dirs;
}
files = dirs = 0;
for (i = 0; i < nextItem; i++)
{
if (!strcmp(fileList[i]->type, "directory"))
dirs++;
else
files++;
}
oldNextItem = nextItem;
memset(s, 0x20, 100);
if (strlen(currPath) > MAX_PATH_LEN)
{
pos = strchr(currPath + MAX_PATH_LEN - 20, '/');
strncpy(s, currPath, pos - currPath + 1);
s[pos - currPath + 1] = '\0';
strcat(s, " ... ");
pos = strrchr(currPath, '/');
strcat(s, pos);
}
else
{
strcpy(s, currPath);
}
*(pos = strchr(s, '\0')) = ' ';
s[MAX_PATH_LEN] = '\0';
printf("found:%4i files,%4i dirs, srch.in:%s \r", totalFiles + files,
totalDirs + dirs, s);
fflush(stdout);
}
pthread_mutex_unlock(&lockFileList);
}