pass arguments from functions to functions

Hi can you help me, I would like to be able to sort file extensions, dates, file size from the main function. Is it ok if I send the arguments to the find_file function to return them to the process function?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <windows.h>
#include <queue>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <cctype>
#include <vector>
#include <sstream>
#include <fstream>
#include <iomanip>

const HANDLE HNULL = INVALID_HANDLE_VALUE;
const int A_DIR = FILE_ATTRIBUTE_DIRECTORY;

std::ostream &operator<<(std::ostream &os, FILETIME
	const &ft)
{
	SYSTEMTIME st;
	FileTimeToSystemTime(&ft, &st);
	return os << st.wHour << ":" << st.wMinute << ":" << st.wSecond << " " << st.wYear << "/" << st.wMonth << "/" << st.wDay;
}

int get_file_size(std::string filename)
{
	FILE *p_file = NULL;
	p_file = fopen(filename.c_str(), "rb");
	fseek(p_file, 0, SEEK_END);
	int size = ftell(p_file);
	fclose(p_file);
	return size;
}

void process(std::string
	const &path, WIN32_FIND_DATA
	const &file)
{
	std::string file_perso;
	file_perso = file.cFileName;
	std::string ext_file;
	if (file_perso.find_last_of(".") != std::string::npos)
	{
		ext_file = file_perso.substr(file_perso.find_last_of(".") + 1);
	}

	std::string path_file = path + file.cFileName;

	std::cout << path << file.cFileName << "\n";
	std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
	std::cout << "\n";
}

void find_file(std::string
	const &folder_name, std::string
	const &fmask)
{
	HANDLE finder;
	WIN32_FIND_DATA file;
	std::priority_queue<std::string, std::vector<std::string>, std::greater<std::string>> dirs;
	dirs.push(folder_name);

	do {
		std::string path = dirs.top();
		dirs.pop();

		if (path[path.size() - 1] != '\\')
			path += "\\";

		std::string mask = path + fmask;

		if (HNULL == (finder = FindFirstFile(mask.c_str(), &file)))
		{
			continue;
		}

		do { 	if (!(file.dwFileAttributes &A_DIR))
				process(path, file);
		} while (FindNextFile(finder, &file));
		FindClose(finder);
		if (HNULL == (finder = FindFirstFile((path + "*").c_str(), &file)))
			continue;
		do { 	if ((file.dwFileAttributes &A_DIR) && (file.cFileName[0] != '.'))
				dirs.push(path + file.cFileName);
		} while (FindNextFile(finder, &file));
		FindClose(finder);
	} while (!dirs.empty());
}

int main(int argc, char **argv)
{
	if (argc > 2)
		find_file(argv[1], argv[2]);
	else
		find_file("C:\\", "*");
	return 0;
}


the ideal would be to be able to type a command like this:
find.exe C:\*.txt "meal"

to search for text files containing meal in the file title for example.
Last edited on
I searched to sort the files by dates, and I found part of the code on stackoverflow.com, I'll try to make it work with what I've already done :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <Windows.h>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>

class file
{
	std::string name;
	FILETIME time;
	public:
		bool operator < (file
			const &other) const
		{
			return CompareFileTime(&time, &other.time) == 1;
		}

	friend std::ostream &operator<<(std::ostream &os, file
		const &f)
	{
		SYSTEMTIME st;
		FileTimeToSystemTime(&f.time, &st);
		return os << std::setw(20) << f.name << "\t" << st.wHour << ":" << st.wMinute << ":" << st.wSecond << " " << st.wYear << "/" << st.wMonth << "/" << st.wDay;
	}

	file(WIN32_FIND_DATA
		const &d): name(d.cFileName), time(d.ftCreationTime) {}
};

int main()
{
	std::vector<std::string > inputs
	{
		"a.txt", "b.txt" };

	std::vector<file> files;

	std::transform(inputs.begin(), inputs.end(),
		std::back_inserter(files),
	[](std::string
			const &fname)
		{
			WIN32_FIND_DATA d;
			HANDLE h = FindFirstFile(fname.c_str(), &d);
			FindClose(h);
			return d;
		}
);

	std::sort(files.begin(), files.end());
	std::copy(files.begin(), files.end(),
		std::ostream_iterator<file> (std::cout, "\n"));
}
I can sort the files found by date and time using the previous code but I can't find the other information.
Take a small folder to test otherwise it may take time to get the result from the root (correct line 120 for this).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <windows.h>
#include <queue>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <cctype>
#include <vector>
#include <sstream>
#include <fstream>
#include <iomanip>

const HANDLE HNULL = INVALID_HANDLE_VALUE;
const int A_DIR = FILE_ATTRIBUTE_DIRECTORY;

std::vector<std::string > inputs;

class file
{
	std::string name;
	FILETIME time;
	public:
		bool operator < (file
			const &other) const
		{
			return CompareFileTime(&time, &other.time) == 1;
		}

	friend std::ostream &operator<<(std::ostream &os, file
		const &f)
	{
		SYSTEMTIME st;
		FileTimeToSystemTime(&f.time, &st);
		return os << std::setw(20) << f.name << "\t" << st.wHour << ":" << st.wMinute << ":" << st.wSecond << " " << st.wYear << "/" << st.wMonth << "/" << st.wDay;
	}

	file(WIN32_FIND_DATA
		const &d): name(d.cFileName), time(d.ftCreationTime) {}
};

std::ostream &operator<<(std::ostream &os, FILETIME const &ft)
{
	SYSTEMTIME st;
	FileTimeToSystemTime(&ft, &st);
	return os << st.wHour << ":" << st.wMinute << ":" << st.wSecond << " " << st.wYear << "/" << st.wMonth << "/" << st.wDay;
}

int get_file_size(std::string filename)
{
	FILE *p_file = NULL;
	p_file = fopen(filename.c_str(), "rb");
	fseek(p_file, 0, SEEK_END);
	int size = ftell(p_file);
	fclose(p_file);
	return size;
}

void process(std::string const &path, WIN32_FIND_DATA const &file)
{
	std::string file_perso;
	file_perso = file.cFileName;
	std::string ext_file;
	if (file_perso.find_last_of(".") != std::string::npos)
	{
		ext_file = file_perso.substr(file_perso.find_last_of(".") + 1);
	}

	std::string path_file = path + file.cFileName;

	inputs.push_back(path_file);

	/*
	std::cout <<path << file.cFileName <<"\n";
	std::cout <<file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
	std::cout <<"\n";
	*/
}

void find_file(std::string const &folder_name, std::string const &fmask)
{
	HANDLE finder;
	WIN32_FIND_DATA file;
	std::priority_queue<std::string, std::vector<std::string>, std::greater<std::string>> dirs;
	dirs.push(folder_name);

	do {
		std::string path = dirs.top();
		dirs.pop();

		if (path[path.size() - 1] != '\\')
			path += "\\";

		std::string mask = path + fmask;

		if (HNULL == (finder = FindFirstFile(mask.c_str(), &file)))
		{
			continue;
		}

		do {
			if (!(file.dwFileAttributes &A_DIR))
				process(path, file);
		} while (FindNextFile(finder, &file));
		FindClose(finder);
		if (HNULL == (finder = FindFirstFile((path + "*").c_str(), &file)))
			continue;
		do {
			if ((file.dwFileAttributes &A_DIR) && (file.cFileName[0] != '.'))
				dirs.push(path + file.cFileName);
		} while (FindNextFile(finder, &file));
		FindClose(finder);
	} while (!dirs.empty());
}

int main(int argc, char **argv)
{
	if (argc > 2)
		find_file(argv[1], argv[2]);
	else
		find_file("C:\\", "*");
	std::vector<file> files;

	std::transform(inputs.begin(), inputs.end(),
		std::back_inserter(files), [](std::string
			const &fname)
		{
			WIN32_FIND_DATA d;
			HANDLE h = FindFirstFile(fname.c_str(), &d);
			FindClose(h);
			return d;
		}

);

	std::sort(files.begin(), files.end());
	for (auto &name_of_file: files)
	{
		std::cout << name_of_file << '\n';
	}

	return 0;

}
Last edited on
You seem to be using windows' tools; (windows.h) and I believe you can load the files into a file explorer window/widget/whatever it is and sort them in the desired ways using that. Its 'as if' you had popped up the window and the user clicked the date column, for example, which sorts by date (either ascending or descending). I don't think you have to re-invent this; it already knows how to sort by {name, type, date, size, more}.
You can use these without actually displaying them; they can work as containers (same as how an edit box can be hidden and used to store text for internal use).


It's to better display the search results but I have to pass the search arguments from the main function to the function that displays the information found: the process function for my start code. I would like to be able to sort the results. I'm doing this program for someone close to me because I want to do something complete. Can you help me with that?


As I said at the beginning, the ideal would be to be able to type a command like this:
find.exe C:\*.txt "meal"

to search for text files containing meal in the file title for example.

or the command:
find.exe C:\*.jpg < 2000000
to find all jpeg files smaller than 2MB.

or the order

find.exe C:\*.doc 2018/11/ to 2020/08

to find all Word files created between November 2018 and August 2020. This is my goal.


Thought you would make it possible to rank it according to the user's needs, that would be perfect, but I'm not sure I'll be able to do what I want.
Last edited on
This is the first step to find all the txt files on the hard drive that are less than 300 bytes in size, type the following command:

program_name.exe c:\ *.txt 300

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <windows.h>
#include <queue>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <cctype>
#include <vector>
#include <sstream>
#include <fstream>
#include <iomanip>

const HANDLE HNULL = INVALID_HANDLE_VALUE;
const int A_DIR = FILE_ATTRIBUTE_DIRECTORY;

std::ostream &operator<<(std::ostream &os, FILETIME
	const &ft)
{
	SYSTEMTIME st;
	FileTimeToSystemTime(&ft, &st);
	return os << st.wHour << ":" << st.wMinute << ":" << st.wSecond << " " << st.wYear << "/" << st.wMonth << "/" << st.wDay;
}

int get_file_size(std::string filename)
{
	FILE *p_file = NULL;
	p_file = fopen(filename.c_str(), "rb");
	fseek(p_file, 0, SEEK_END);
	int size = ftell(p_file);
	fclose(p_file);
	return size;
}

void process(std::string
	const &path, WIN32_FIND_DATA
	const &file, std::string asking_file_size)
{
	std::string file_perso;
	file_perso = file.cFileName;
	std::string ext_file;
	std::string ask_size;
	int asking;
	if (file_perso.find_last_of(".") != std::string::npos)
	{
		ext_file = file_perso.substr(file_perso.find_last_of(".") + 1);
	}

	asking = atoi(asking_file_size.c_str());

	std::string path_file = path + file.cFileName;

	if (asking == 0)
	{
		std::cout << path << file.cFileName << "\n";
		std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
		std::cout << "\n";
	}
	else if (get_file_size(path_file) < asking)
	{
		std::cout << path << file.cFileName << "\n";
		std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
		std::cout << "\n";
	}
}

void find_file(std::string
	const &folder_name, std::string
	const &fmask, std::string asking_file_size)
{
	HANDLE finder;
	WIN32_FIND_DATA file;
	std::priority_queue<std::string, std::vector<std::string>, std::greater<std::string>> dirs;
	dirs.push(folder_name);

	do {
		std::string path = dirs.top();
		dirs.pop();

		if (path[path.size() - 1] != '\\')
			path += "\\";

		std::string mask = path + fmask;

		if (HNULL == (finder = FindFirstFile(mask.c_str(), &file)))
		{
			continue;
		}

		do { 	if (!(file.dwFileAttributes &A_DIR))
				process(path, file, asking_file_size);
		} while (FindNextFile(finder, &file));
		FindClose(finder);
		if (HNULL == (finder = FindFirstFile((path + "*").c_str(), &file)))
			continue;
		do { 	if ((file.dwFileAttributes &A_DIR) && (file.cFileName[0] != '.'))
				dirs.push(path + file.cFileName);
		} while (FindNextFile(finder, &file));
		FindClose(finder);
	} while (!dirs.empty());
}

int main(int argc, char **argv)
{
	if (argc > 3)
		find_file(argv[1], argv[2], argv[3]);
	else
		find_file("C:\\", "*", "0");
	return 0;
}
And the last one I think, but if you could help me optimize the code, that would be great. To find all txt files under 2000 bytes in size and having the word "meal" in the title type the following command :

program_name.exe c:\ *.txt 2000 meal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <windows.h>
#include <queue>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <cctype>
#include <vector>
#include <sstream>
#include <fstream>
#include <iomanip>

const HANDLE HNULL = INVALID_HANDLE_VALUE;
const int A_DIR = FILE_ATTRIBUTE_DIRECTORY;

std::ostream &operator<<(std::ostream &os, FILETIME const &ft)
{
	SYSTEMTIME st;
	FileTimeToSystemTime(&ft, &st);
	return os << st.wHour << ":" << st.wMinute << ":" << st.wSecond << " " << st.wYear << "/" << st.wMonth << "/" << st.wDay;
}

int get_file_size(std::string filename)
{
	FILE *p_file = NULL;
	p_file = fopen(filename.c_str(), "rb");
	fseek(p_file, 0, SEEK_END);
	int size = ftell(p_file);
	fclose(p_file);
	return size;
}

void process(std::string const &path, WIN32_FIND_DATA const &file, std::string asking_file_size, std::string word_in_title)
{
	std::string file_perso;
	file_perso = file.cFileName;
	std::string ext_file;
	std::string ask_size;
	int asking;
	if (file_perso.find_last_of(".") != std::string::npos)
	{
		ext_file = file_perso.substr(file_perso.find_last_of(".") + 1);
	}

	asking = atoi(asking_file_size.c_str());

	std::string path_file = path + file.cFileName;

	if (asking == 0)
	{
		if (word_in_title == "-")
		{
			std::cout << path << file.cFileName << "\n";
			std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
			std::cout << "\n";
		}
		else
		{
			std::size_t founda = file_perso.find(word_in_title);
			if (founda != std::string::npos)
			{
				std::cout << path << file.cFileName << "\n";
				std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
				std::cout << "\n";
			}
		}
	}
	else if (get_file_size(path_file) < asking)
	{
		if (word_in_title == "-")
		{
			std::cout << path << file.cFileName << "\n";
			std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
			std::cout << "\n";
		}
		else
		{
			std::size_t founda = file_perso.find(word_in_title);
			if (founda != std::string::npos)
			{
				std::cout << path << file.cFileName << "\n";
				std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
				std::cout << "\n";
			}
		}
	}
}

void find_file(std::string const &folder_name, std::string const &fmask, std::string asking_file_size, std::string word_in_title)
{
	HANDLE finder;
	WIN32_FIND_DATA file;
	std::priority_queue<std::string, std::vector<std::string>, std::greater<std::string>> dirs;
	dirs.push(folder_name);

	do {
		std::string path = dirs.top();
		dirs.pop();

		if (path[path.size() - 1] != '\\')
			path += "\\";

		std::string mask = path + fmask;

		if (HNULL == (finder = FindFirstFile(mask.c_str(), &file)))
		{
			continue;
		}

		do {
			if (!(file.dwFileAttributes &A_DIR))
				process(path, file, asking_file_size, word_in_title);
		} while (FindNextFile(finder, &file));
		FindClose(finder);
		if (HNULL == (finder = FindFirstFile((path + "*").c_str(), &file)))
			continue;
		do {
			if ((file.dwFileAttributes &A_DIR) && (file.cFileName[0] != '.'))
				dirs.push(path + file.cFileName);
		} while (FindNextFile(finder, &file));
		FindClose(finder);
	} while (!dirs.empty());
}

int main(int argc, char **argv)
{
	if (argc > 4)
		find_file(argv[1], argv[2], argv[3], argv[4]);
	else
		find_file("C:\\", "*", "0", "-");
	return 0;
}


I miss sorting by dates!
Last edited on
Hello, could you help me, I have a problem interpreting the arguments of the main function. They are in char in the main function and I use them in std::string. Is it possible to have std::string arguments in the main function?

Because when I ask *.odt for Open Office files it doesn't work I think the error is there?
Is it possible to have std::string arguments in the main function?

your compiler may support it, but the standard is c-string.
just convert them if you need to (this is wasteful normally, an extra pointless copy, but if it makes you happy)
string argx = argv[x];

you could also get rid of the & and see if it will just do it for you? I am not sure on that one... I have never tried to do a conversion into a reference and am unsure what happens. Also, try printing the strings you got in find_file to see if it is indeed the problem? Maybe they got there OK and you have a different problem, don't think** where the problem is, find it...

** here, think probably means 'guess'
Last edited on
I removed the & and I put the {} missing for some loops, for most extensions the program works but there are still some errors.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include <windows.h>
#include <queue>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <cctype>
#include <vector>
#include <sstream>
#include <fstream>
#include <iomanip>

const HANDLE HNULL = INVALID_HANDLE_VALUE;
const int A_DIR = FILE_ATTRIBUTE_DIRECTORY;

std::ostream &operator<<(std::ostream &os, FILETIME const &ft)
{
	SYSTEMTIME st;
	FileTimeToSystemTime(&ft, &st);
	return os << st.wHour << ":" << st.wMinute << ":" << st.wSecond << " " << st.wYear << "/" << st.wMonth << "/" << st.wDay;
}

int get_file_size(std::string filename)
{
	FILE *p_file = NULL;
	p_file = fopen(filename.c_str(), "rb");
	fseek(p_file, 0, SEEK_END);
	int size = ftell(p_file);
	fclose(p_file);
	return size;
}

void process(std::string
	const path, WIN32_FIND_DATA
	const file, std::string asking_file_size, std::string word_in_title)
{
	std::string file_perso;
	file_perso = file.cFileName;
	std::string ext_file;
	std::string ask_size;
	int asking;
	if (file_perso.find_last_of(".") != std::string::npos)
	{
		ext_file = file_perso.substr(file_perso.find_last_of(".") + 1);
	}

	asking = atoi(asking_file_size.c_str());

	std::string path_file = path + file.cFileName;

	if (asking == 0)
	{
		if (word_in_title == "-")
		{
			std::cout << path << file_perso << "\n";
			std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
			std::cout << "\n";
		}
		else if (word_in_title != "-")
		{
			std::size_t found_one = file_perso.find(word_in_title);
			if (found_one != std::string::npos)
			{
				std::cout << path << file_perso << "\n";
				std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
				std::cout << "\n";
			}
		}
	}
	else if (get_file_size(path_file) < asking)
	{
		if (word_in_title == "-")
		{
			std::cout << path << file_perso << "\n";
			std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
			std::cout << "\n";
		}
		else if (word_in_title != "-")
		{
			std::size_t found_two = file_perso.find(word_in_title);
			if (found_two != std::string::npos)
			{
				std::cout << path << file_perso << "\n";
				std::cout << file.ftCreationTime << "\t" << ext_file << "\t" << get_file_size(path_file) << " octets" << "\n";
				std::cout << "\n";
			}
		}
	}
}

void find_file(std::string
	const folder_name, std::string
	const fmask, std::string asking_file_size, std::string word_in_title)
{
	HANDLE finder;
	WIN32_FIND_DATA file;
	std::priority_queue<std::string, std::vector<std::string>, std::greater<std::string>> dirs;
	dirs.push(folder_name);

	do {
		std::string path = dirs.top();
		dirs.pop();

		if (path[path.size() - 1] != '\\')
		{
			path += "\\";
		}

		std::string mask = path + fmask;

		if (HNULL == (finder = FindFirstFile(mask.c_str(), &file)))
		{
			continue;
		}

		do {
			if (!(file.dwFileAttributes &A_DIR))
			{
				process(path, file, asking_file_size, word_in_title);
			}
		} while (FindNextFile(finder, &file));

		FindClose(finder);

		if (HNULL == (finder = FindFirstFile((path + "*").c_str(), &file)))
		{
			continue;
		}

		do {
			if ((file.dwFileAttributes &A_DIR) && (file.cFileName[0] != '.'))
			{
				dirs.push(path + file.cFileName);
			}
		} while (FindNextFile(finder, &file));
		FindClose(finder);
	} while (!dirs.empty());
}

int main(int argc, char **argv)
{
	// usage :   program_name.exe c:\ *.txt 300 -
	// program_name.exe path ext  file size word_to_find_in_file_title

	if (argc > 4)
	{
		find_file(argv[1], argv[2], argv[3], argv[4]);
	}
	else
	{
		find_file("C:\\", "*", "0", "-");
	}

	return 0;
}
Last edited on
Topic archived. No new replies allowed.