error c2228 left of '._ptr' must have class/struct/union

I am getting this error and I cant figure out why. I am very new to boost filesystem library

error c2228 left of '._ptr' must have class/struct/union

EDIT: If it helps any the error is in the filesystem Library line 1749

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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
  #include <iostream>
#include <string>
#include <vector>
using namespace std;

#include <filesystem>
using namespace std::tr2::sys;

void fileSearch (string switches, path const& f, unsigned k = 0)
{
	int cpp = 0, c= 0, h= 0, hpp= 0, hxx= 0, java= 0, totalClass= 0, avi= 0, mkv= 0, mpeg= 0, mp4= 0, mp3= 0;
	long long cppBy = 0, cBy= 0, hBy= 0, hppBy= 0, hxxBy= 0, javaBy= 0, totalClassBy= 0, aviBy= 0, mkvBy= 0, mpegBy= 0, mp4By= 0, mp3By= 0;
	long long totalBytes = 0;
	string indent( k , '\t' );
	directory_iterator temp;		// used to temporarily store d
	directory_iterator d( f );		// beginning of folder 'f'
	directory_iterator e;			// end of any folder
	bool isReverse = false;
	bool isRecursive = false;
	for (unsigned check = 0; check < switches.size(); ++check)
	{
		if (switches[check] == 'r')
		{
			isRecursive = true;
		}

		else if (switches[check] == 'R')
		{
			isReverse = true;
		}
	}

	for (unsigned int i = 0; i < switches.size(); ++i)
	{
		if (switches[i] == 'c')	// c: search for c++ files (c++ files extension: .c,.cpp,.h,.hpp,.hxx)
		{
			if ( d->path().extension() == ".c")
			{
				c++;
				cBy += file_size(is_directory( d->status()));
					
			}

			else if ( d->path().extension() == ".cpp")
			{
				cpp++;
				cppBy += file_size(is_directory( d->status()));
					
			}

			else if ( d->path().extension() == ".h")
			{
				h++;
				hBy += file_size(is_directory( d->status()));
					
			}

			else if ( d->path().extension() == ".hpp")
			{
				hpp++;
				hppBy += file_size(is_directory( d->status()));
					
			}

			else if ( d->path().extension() == ".hxx")
			{
				hxx++;
				hxxBy += file_size(is_directory( d->status()));
					
			}
		}				
		else if (switches[i] == 'j') // j: search for java files (java files extension: .java,.class)
		{
			if ( d->path().extension() == ".java")
			{
				java++;
				javaBy += file_size(is_directory( d->status()));
					
			}

			else if ( d->path().extension() == ".class")
			{
				totalClass++;
				totalClassBy += file_size(is_directory( d->status()));
					
			}
		}
		else if (switches[i] == 'm') // m: search for multimedia files (multimedia files extension: .avi,.mkv,.mpeg,.mp4,.mp3)
		{
			if ( d->path().extension() == ".avi")
			{
				avi++;
				aviBy += file_size(is_directory( d->status()));
					
			}

			else if ( d->path().extension() == ".mkv")
			{
				mkv++;
				mkvBy += file_size(is_directory( d->status()));
					
			}

			else if ( d->path().extension() == ".mpeg")
			{
				mpeg++;
				mpegBy += file_size(is_directory( d->status()));
					
			}

			else if ( d->path().extension() == ".mp4")
			{
				mp4++;
				mp4By += file_size(is_directory( d->status()));
					
			}

			else if ( d->path().extension() == ".mp3")
			{
				mp3++;
				mp3By += file_size(is_directory( d->status()));
					
			}
		}
		else if (switches[i] == 'x') // x: search extensions using a regex expression (ie:  -x “\.(docx|xlsx)”)
		{

		}
		else if (switches[i] == 'r') // r: process all folders recursively.
		{
			
		}
		else if (switches[i] == 'R') // R: list the files in reverse order.
		{

		}
		else if (switches[i] == 's') // s: sort the files by ascending file size – or descending if the R switch is provided.
		{

		}
		else if (switches[i] == 'h') // h: shows the help usage for running the program
		{

		}
		else
		{	
				
		}
	}

	totalBytes += totalClass; 
	totalBytes += javaBy;
	totalBytes += hxxBy;
	totalBytes += hppBy;
	totalBytes += hBy;
	totalBytes += cppBy;
	totalBytes += cBy;
	totalBytes += aviBy;
	totalBytes += mkvBy;
	totalBytes += mpegBy;
	totalBytes += mp3By;
	totalBytes += mp4By;

	//temp = d;
	for( ; d != e; ++d ) // Outputs folder path
	{
		cout << indent << "Scanning: " << d->path();
	}

	cout << endl;

	if (isRecursive == false && isReverse == false)
	{
		cout << indent << system_complete( f ) << endl;
		directory_iterator d( f );		// beginning of folder 'f'
		directory_iterator e;			// end of any folder
		//temp = d;		
		for( ; d != e; ++d ) 
		{
			cout << indent << d->path().extension() << " " << file_size(is_directory( d->status())) << endl;
		}
	}

	else if (isRecursive == true && isReverse == false)
	{
	}

	else if (isRecursive == false && isReverse == true)
	{		
		string indent( k , '\t' );	
		cout << indent << system_complete( f ) << endl;
				
					
		for( ; d != e; ++d ) 
		{
			cout << indent << d->path() << ( is_directory( d->status() ) ? " [dir]" : "" ) <<
					" ext=" << d->path().extension() << endl;
		}
	}

	else if (isRecursive == true && isReverse == true)
	{
		recursive_directory_iterator d( f ), e;
		for( ; d != e; ++d ) 
		{
			cout << d->path() << ( is_directory( d->status() ) ? " [dir]" : "" ) << endl;
		}
	}

	else 
	{
		cout << "error" << endl;
	}
}

int main(int argc, char* argv[])
{
	path folder = "..";
	string switches, argStr;
	string pathStart;
	
	// boolean switches declared and initialized to off
	bool searchCPP = false, searchJ = false, searchMM = false, searchRegex = false,
		 searchRecursive = false, searchReverse = false, sortFiles = false, help = false; 
	if (argc == 2)
	{
		argStr = argv[1];
		if (argStr[0] == '-' || argStr[0] == 'c' || argStr[0] == 'j' || argStr[0] == 'm' || argStr[0] == 'x'
			|| argStr[0] == 'r' || argStr[0] == 'R' || argStr[0] == 's' || argStr[0] == 'h')
		{
			switches = argStr;
		}

		else
		{
			pathStart = argStr;
		}
	}

	else if (argc == 3)
	{
		argStr = argv[1];

		if (argStr[0] == '-' || argStr[0] == 'c' || argStr[0] == 'j' || argStr[0] == 'm' || argStr[0] == 'x'
		|| argStr[0] == 'r' || argStr[0] == 'R' || argStr[0] == 's' || argStr[0] == 'h')
		{
			switches = argStr;
			pathStart = argv[2];
		}

		else if (argStr[1] == ':')
		{
			pathStart = argStr;
			switches = argv[2];
		}

		else
		{
			cout << "Incorrect Argument entered.. Exiting" << endl;
			return EXIT_FAILURE;
		}
	}

	else if (argc > 3)
	{
		cout << "Too many arguments entered... Exiting" << endl;
		return EXIT_FAILURE;
	}

	if (switches.size() > 0)
	{
		for (unsigned int i = 0; i < switches.size(); ++i)
		{
			if (switches[0] == '-')
				continue;
			else if (switches[i] == 'c')
				searchCPP = true;
			else if (switches[i] == 'j')
				searchJ = true;
			else if (switches[i] == 'm')
				searchMM = true;
			else if (switches[i] == 'x')
				searchRegex = true;
			else if (switches[i] == 'r')
				searchRecursive = true;
			else if (switches[i] == 'R')
				searchReverse = true;
			else if (switches[i] == 's')
				sortFiles = true;
			else if (switches[i] == 'h')
				help = true;
			else
			{
				cout << "Incorrect switch entered... Exiting" << endl;
				return EXIT_FAILURE;
			}
		}
	}
	
	fileSearch(switches, folder);
	
	return EXIT_SUCCESS;
}
Last edited on
Was using d->path().extension() instead of assing d->path() to a variable of type path ex:

path p;
p = d->path();

p.extension();
Topic archived. No new replies allowed.