Hi all.

I wrote a relatively big program that scans specified directories and it will print the files found depending on the options entered.

The program works extremely nice. But now I want to add progress percentage displaying. The big problem that I have is that the dir() function (the one that scans the directories and prints the results) is recursive. So, I believe that I should make the function for the progress separately, and call the progress() function every time the dir() function, for example, scans a file. Every time it scans a file, then the progress function will calculate the current progress, make a carriage return and print to screen. The only code I have for that function so far is this:

Code:
void progress(bool start) {
	if(start) {
	// first call, get total bytes to be scanned
	
	} else {
	// print out progress
	}
	
	return;
}
Suddenly I thought, that to calculate the percentage, I first need to know the total files (or bytes) that are going to be scanned BEFORE I start scanning, so that I could calculate the percentage with the difference of the bytes scanned and the total bytes to be scanned. But scanning for the total size first would take a lot of time! How could I do this better and faster? Can somebody help?

Thanks a lot.