Subversion Repositories spk

Rev

Rev 185 | Rev 197 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 185 Rev 196
Line 13... Line 13...
13
#define ACCESS _access
13
#define ACCESS _access
14
#else
14
#else
15
#include <dirent.h>
15
#include <dirent.h>
16
#define ACCESS access
16
#define ACCESS access
17
#endif
17
#endif
-
 
18
 
-
 
19
#define TOSTRING(s)  std::string(s.begin(), s.end())
18
 
20
 
19
/////////////////////////////////////////
21
/////////////////////////////////////////
20
// STATIC FUNCTIONS
22
// STATIC FUNCTIONS
21
bool CDirIO::Exists(const Utils::String &dir)
23
bool CDirIO::Exists(const Utils::WString &dir)
22
{
24
{
23
	return CDirIO(dir).exists();
25
	return CDirIO(dir).exists();
-
 
26
}
-
 
27
 
-
 
28
bool CDirIO::IsEmptyDir(const Utils::CStringList& dirList)
-
 
29
{
-
 
30
	// not found any files, most likly empty
-
 
31
	if (dirList.empty())
-
 
32
		return true;
-
 
33
	// check for any valid files
-
 
34
 
-
 
35
	for (auto itr = dirList.begin(); itr != dirList.end(); itr++)
-
 
36
	{
-
 
37
		Utils::String d = (*itr)->str;
-
 
38
		if (d == "." || d == "..")
-
 
39
			continue;
-
 
40
 
-
 
41
		// found something
-
 
42
		return false;
-
 
43
	}
-
 
44
 
-
 
45
	return true;
-
 
46
}
-
 
47
 
-
 
48
bool CDirIO::IsEmptyDir(const Utils::WStringList& dirList)
-
 
49
{
-
 
50
	// not found any files, most likly empty
-
 
51
	if (dirList.empty())
-
 
52
		return true;
-
 
53
	// check for any valid files
-
 
54
 
-
 
55
	for (auto itr = dirList.begin(); itr != dirList.end(); itr++)
-
 
56
	{
-
 
57
		Utils::WString d = (*itr)->str;
-
 
58
		if (d == L"." || d == L"..")
-
 
59
			continue;
-
 
60
 
-
 
61
		// found something
-
 
62
		return false;
-
 
63
	}
-
 
64
 
-
 
65
	return true;
24
}
66
}
25
 
67
 
26
 
68
 
27
////////////////////////////////////////
69
////////////////////////////////////////
28
// Ctor/Dtor
70
// Ctor/Dtor
Line 33... Line 75...
33
 
75
 
34
CDirIO::~CDirIO()
76
CDirIO::~CDirIO()
35
{
77
{
36
}
78
}
37
 
79
 
38
CDirIO::CDirIO(const Utils::String &dir)
80
CDirIO::CDirIO(const Utils::WString &dir)
39
{
81
{
40
	setDir(dir);
82
	setDir(dir);
41
}
83
}
42
 
84
 
43
CDirIO::CDirIO(CFileIO *file)
85
CDirIO::CDirIO(CFileIO *file)
Line 46... Line 88...
46
}
88
}
47
 
89
 
48
/////////////////////////////////////////////////////////
90
/////////////////////////////////////////////////////////
49
//
91
//
50
 
92
 
51
void CDirIO::setDir(const Utils::String& dir)
93
void CDirIO::setDir(const Utils::WString& dir)
52
{
94
{
53
	m_sCurrentDir = dir;
95
	m_sCurrentDir = dir;
54
	m_sCurrentDir.toFilename();
96
	m_sCurrentDir.toFilename();
55
}
97
}
56
 
98
 
57
bool CDirIO::exists() const
99
bool CDirIO::exists() const
58
{
100
{
59
	Utils::String dir = m_sCurrentDir;
101
	Utils::WString dir = m_sCurrentDir;
60
 
102
 
61
	if (dir.empty())
103
	if (dir.empty())
62
		return false;
104
		return false;
63
 
105
 
64
	if (ACCESS(dir.c_str(), 0) == 0)
106
	if (ACCESS(TOSTRING(dir).c_str(), 0) == 0)
65
		return true;
107
		return true;
66
 
108
 
67
	return false;
109
	return false;
68
}
110
}
69
 
111
 
70
bool CDirIO::exists(const Utils::String &dir) const
112
bool CDirIO::exists(const Utils::WString &dir) const
71
{
113
{
72
	Utils::String d = _parseDir(dir);
114
	Utils::WString d = _parseDir(dir);
73
 
115
 
74
	if (d.empty())
116
	if (d.empty())
75
		return false;
117
		return false;
76
 
118
 
77
	if (ACCESS(d.c_str(), 0) == 0)
119
	if (ACCESS(TOSTRING(d).c_str(), 0) == 0)
78
		return true;
120
		return true;
79
 
121
 
80
	return false;
122
	return false;
81
}
123
}
82
 
124
 
83
Utils::String CDirIO::_parseDir(const Utils::String &dir) const
125
Utils::WString CDirIO::_parseDir(const Utils::WString &dir) const
84
{
126
{
85
	Utils::String sDir = dir.asFilename();
127
	Utils::WString sDir = dir.asFilename();
86
	if ( !m_sCurrentDir.empty() && !sDir.isin(":") )
128
	if ( !m_sCurrentDir.empty() && !sDir.contains(L":") )
87
	{
129
	{
88
		if ( sDir.empty() )
130
		if ( sDir.empty() )
89
			sDir = m_sCurrentDir;
131
			sDir = m_sCurrentDir;
90
		else
132
		else
91
			sDir = m_sCurrentDir + "/" + sDir;
133
			sDir = m_sCurrentDir + L"/" + sDir;
92
	}
134
	}
93
 
135
 
94
	return sDir.asFilename();
136
	return sDir.asFilename();
95
}
137
}
96
 
138
 
97
bool CDirIO::isDir(const Utils::String &sDir) const
139
bool CDirIO::isDir(const Utils::WString &sDir) const
98
{
140
{
99
	Utils::String dir = _parseDir(sDir);
141
	Utils::WString dir = _parseDir(sDir);
100
	if (ACCESS(dir.c_str(), 0) != -1)
142
	if (ACCESS(TOSTRING(dir).c_str(), 0) != -1)
101
	{
143
	{
102
		struct stat status;
144
		struct stat status;
103
		stat(dir.c_str(), &status);
145
		stat(TOSTRING(dir).c_str(), &status);
104
 
146
 
105
		if (status.st_mode & S_IFDIR)
147
		if (status.st_mode & S_IFDIR)
106
			return true;
148
			return true;
107
	}
149
	}
108
	else {
150
	else {
109
		return !dir.token("/", -1).isin(".");
151
		return !dir.token(L"/", -1).contains(L".");
110
	}
152
	}
111
 
153
 
112
	return false;
154
	return false;
113
}
155
}
114
 
156
 
115
bool CDirIO::isDir() const
157
bool CDirIO::isDir() const
116
{
158
{
117
	return isDir(m_sCurrentDir);
159
	return isDir(m_sCurrentDir);
118
}
160
}
119
 
161
 
120
bool CDirIO::isFile() const
162
bool CDirIO::isFile() const
121
{
163
{
122
	return isFile(m_sCurrentDir);
164
	return isFile(m_sCurrentDir);
123
}
165
}
124
bool CDirIO::isFile(const Utils::String &sDir) const
166
bool CDirIO::isFile(const Utils::WString &sDir) const
125
{
167
{
126
	Utils::String dir = _parseDir(sDir);
168
	Utils::WString dir = _parseDir(sDir);
127
	if (ACCESS(dir.c_str(), 0) != -1)
169
	if (ACCESS(TOSTRING(dir).c_str(), 0) != -1)
128
	{
170
	{
129
		struct stat status;
171
		struct stat status;
130
		stat(dir.c_str(), &status);
172
		stat(TOSTRING(dir).c_str(), &status);
131
 
173
 
132
		if (status.st_mode & S_IFDIR)
174
		if (status.st_mode & S_IFDIR)
133
			return false;
175
			return false;
134
		else
176
		else
135
			return true;
177
			return true;
136
	}
178
	}
137
	else {
179
	else {
138
		return dir.token("/", -1).isin(".");
180
		return dir.token(L"/", -1).contains(L".");
139
	}
181
	}
140
 
182
 
141
	return false;
183
	return false;
142
}
184
}
143
 
185
 
144
 
186
 
145
bool CDirIO::create() const
187
bool CDirIO::create() const
146
{
188
{
147
	return create(Utils::String::Null());
189
	return create(Utils::String::Null());
148
}
190
}
149
bool CDirIO::create(const Utils::String &sDir) const
191
bool CDirIO::create(const Utils::WString &sDir) const
150
{
192
{
151
	Utils::String dir = sDir;
193
	Utils::WString dir = sDir;
152
	if ( dir.empty() )
194
	if ( dir.empty() )
153
		dir = m_sCurrentDir;
195
		dir = m_sCurrentDir;
154
	dir = _parseDir(dir);
196
	dir = _parseDir(dir);
155
 
197
 
156
	// split up directorys
198
	// split up directorys
157
	int max = 0;
199
	std::vector<std::wstring> dirs;
158
	Utils::String *dirs = dir.findReplace( "/", "\\" ).findReplace( "\\\\", "\\" ).tokenise("\\&quot;, &;max );
200
	if(dir.findReplace(L"/", L"\\").findReplace(L"\\\\", L"\\").tokenise(L"\\&quot;, dirs))
159
 
201
	{
160
	// check if full dir, or relative
202
		// check if full dir, or relative
161
	int start = 1;
203
		size_t start = 1;
162
	Utils::String curDir;
204
		Utils::WString curDir = dirs.front();
163
	
-
 
164
	if ( dirs && max )
-
 
165
		curDir = dirs[0];
-
 
166
 
205
 
167
	if ( !curDir.isin(":") )
206
		if (!curDir.contains(L":"))
168
	{
207
		{
169
		curDir = m_sCurrentDir;
208
			curDir = m_sCurrentDir;
170
		start = 0;
209
			start = 0;
171
	}
210
		}
172
 
211
 
173
	// process each dir
212
		// process each dir
174
	for ( int i = start; i <; max; i++ )
213
		for (size_t i = start; i <; dirs.size(); i++)
175
	{
214
		{
176
		if ( !curDir.empty() )
215
			if (!curDir.empty())
177
			curDir += "/";
216
				curDir += L"/";
178
		curDir += dirs[i];
217
			curDir += dirs.at(i);
179
 
218
 
180
		// check if the directory exists
219
			// check if the directory exists
181
		if ( !exists(curDir) )
220
			if (!exists(curDir))
182
		{
221
			{
183
#ifdef _WIN32
222
#ifdef _WIN32
184
			if ( _mkdir(curDir.c_str()) )
223
				if (_mkdir(TOSTRING(curDir).c_str()))
185
#else
224
#else
186
			if ( mkdir(curDir.c_str(), 0755) )
225
				if (mkdir(TOSTRING(curDir).c_str(), 0755))
187
#endif
226
#endif
188
			{
-
 
189
				CLEANSPLIT(dirs, max);
-
 
190
				return false;
227
					return false;
191
			}
228
			}
192
		}
229
		}
193
	}
230
	}
194
 
-
 
195
	CLEANSPLIT(dirs, max);
-
 
196
 
231
 
197
	return true;
232
	return true;
198
}
233
}
199
 
234
 
200
bool CDirIO::move(const Utils::String &sTo)
235
bool CDirIO::move(const Utils::WString &sTo)
201
{
236
{
202
	Utils::String to = _parseDir(sTo);
237
	Utils::WString to = _parseDir(sTo);
203
 
238
 
204
	if (exists(to))
239
	if (exists(to))
205
		return false;
240
		return false;
206
 
241
 
207
	if (!rename(m_sCurrentDir.c_str(), to.c_str()))
242
	if (!rename(TOSTRING(m_sCurrentDir).c_str(), TOSTRING(to).c_str()))
208
	{
243
	{
209
		m_sCurrentDir = to;
244
		m_sCurrentDir = to;
210
		return true;
245
		return true;
211
	}
246
	}
212
 
247
 
213
	return false;
248
	return false;
214
}
249
}
215
 
250
 
216
 
251
 
217
bool CDirIO::move(const Utils::String &sFrom, const Utils::String &sTo)
252
bool CDirIO::move(const Utils::WString &sFrom, const Utils::WString &sTo)
218
{
253
{
219
	Utils::String from = _parseDir(sFrom);
254
	Utils::WString from = _parseDir(sFrom);
220
	Utils::String to = _parseDir(sTo);
255
	Utils::WString to = _parseDir(sTo);
221
 
256
 
222
	if ( !exists(to) )
257
	if ( !exists(to) )
223
	{
258
	{
224
		if ( !create(to) )
259
		if ( !create(to) )
225
			return false;
260
			return false;
226
	}
261
	}
227
 
262
 
228
	if ( !rename(from.c_str(), to.c_str()) )
263
	if ( !rename(TOSTRING(from).c_str(), TOSTRING(to).c_str()) )
229
		return true;
264
		return true;
230
 
265
 
231
	return false;
266
	return false;
232
}
267
}
233
 
268
 
Line 249... Line 284...
249
	}
284
	}
250
 
285
 
251
	return true;
286
	return true;
252
}
287
}
253
 
288
 
254
bool CDirIO::removeDir(const Utils::String& dir, bool doFiles, bool recursive, Utils::CStringList* errors)
289
bool CDirIO::removeDir(const Utils::WString& dir, bool doFiles, bool recursive, Utils::CStringList* errors)
255
{
290
{
256
	// check if the dir is empty
291
	// check if the dir is empty
257
	Utils::CStringList list;
292
	Utils::WStringList list;
258
	if (dirList(list, dir))
293
	if (dirList(list, dir))
259
	{
294
	{
260
		if (checkEmptyDir(list))
295
		if (CDirIO::IsEmptyDir(list))
261
		{
296
		{
262
			Utils::String remDir = _parseDir(dir);
297
			Utils::WString remDir = _parseDir(dir);
263
#ifdef _WIN32
298
#ifdef _WIN32
264
			if (_rmdir(remDir.c_str()) == 0)
299
			if (_rmdir(TOSTRING(remDir).c_str()) == 0)
265
#else
300
#else
266
			if (rmdir(remDir.c_str()) == 0)
301
			if (rmdir(TOSTRING(remDir).c_str()) == 0)
267
#endif
302
#endif
268
			{
303
			{
269
				if (errors)
304
				if (errors)
270
					errors->pushBack(remDir);
305
					errors->pushBack(remDir.toString());
271
			}
306
			}
272
			return true;
307
			return true;
273
		}
308
		}
274
 
309
 
275
		// not empty
310
		// not empty
276
		if (doFiles || recursive)
311
		if (doFiles || recursive)
277
		{
312
		{
278
			for (auto itr = list.begin(); itr != list.end(); itr++)
313
			for (auto itr = list.begin(); itr != list.end(); itr++)
279
			{
314
			{
280
				Utils::String d = (*itr)->str;
315
				Utils::WString d = (*itr)->str;
281
				if (d == "." || d == "..")
316
				if (d == L"." || d == L"..")
282
					continue;
317
					continue;
283
 
318
 
284
				// if its a file
319
				// if its a file
285
				Utils::String fullFile = dir + "\\" + d;
320
				Utils::WString fullFile = dir + "\\" + d;
286
				if (doFiles && isFile(fullFile))
321
				if (doFiles && isFile(fullFile))
287
				{
322
				{
288
					Utils::String remFile = _parseDir(fullFile);
323
					Utils::WString remFile = _parseDir(fullFile);
289
					if (remove(remFile.c_str()) == 0)
324
					if (remove(TOSTRING(remFile).c_str()) == 0)
290
					{
325
					{
291
						if (errors)
326
						if (errors)
292
							errors->pushBack(remFile);
327
							errors->pushBack(remFile.toString());
293
					}
328
					}
294
				}
329
				}
295
				else if (recursive && isDir(fullFile))
330
				else if (recursive && isDir(fullFile))
296
					removeDir(fullFile, doFiles, recursive, errors);
331
					removeDir(fullFile, doFiles, recursive, errors);
297
			}
332
			}
298
		}
333
		}
299
	}
334
	}
300
	list.clear();
335
	list.clear();
301
	// now check if its empty
336
	// now check if its empty
302
	if(dirList(list, dir))
337
	if(dirList(list, dir))
303
	{
338
	{
304
		if (checkEmptyDir(list))
339
		if (CDirIO::IsEmptyDir(list))
305
		{
340
		{
306
			Utils::String remDir = _parseDir(dir);
341
			Utils::WString remDir = _parseDir(dir);
307
#ifdef _WIN32
342
#ifdef _WIN32
308
			if (_rmdir(remDir.c_str()) == 0)
343
			if (_rmdir(TOSTRING(remDir).c_str()) == 0)
309
#else
344
#else
310
			if (rmdir(remDir.c_str()) == 0)
345
			if (rmdir(TOSTRING(remDir).c_str()) == 0)
311
#endif
346
#endif
312
			{
347
			{
313
				if (errors)
348
				if (errors)
314
					errors->pushBack(remDir);
349
					errors->pushBack(remDir.toString());
315
			}
350
			}
316
			return true;
351
			return true;
317
		}
352
		}
318
	}
353
	}
319
	return false;
354
	return false;
320
}
355
}
-
 
356
 
-
 
357
bool CDirIO::dirList(Utils::CStringList& files, Utils::WString dir, Utils::WString filePattern) const
-
 
358
{
-
 
359
	dir = _parseDir(dir);
-
 
360
	if (dir.empty())
-
 
361
		return false;
-
 
362
 
-
 
363
	dir = dir.findReplace("\\", "/");
-
 
364
	if (filePattern.empty())
-
 
365
		dir += "/*";
-
 
366
	else
-
 
367
	{
-
 
368
		dir += "/";
-
 
369
		dir += filePattern;
-
 
370
	}
-
 
371
	dir = dir.findReplace("//", "/");
-
 
372
 
-
 
373
#ifdef _WIN32
-
 
374
	dir = dir.findReplace("/", "\\");
-
 
375
 
-
 
376
	WIN32_FIND_DATA data;
-
 
377
 
-
 
378
	HANDLE h = FindFirstFile(dir.c_str(), & data);
-
 
379
	if (h != INVALID_HANDLE_VALUE)
-
 
380
	{
-
 
381
		std::wstring ws(data.cFileName);
-
 
382
		std::string s(ws.begin(), ws.end());
-
 
383
 
-
 
384
		Utils::String checkFile(s);
-
 
385
		if (!checkFile.Compare(".") && !checkFile.Compare(".."))
-
 
386
			files.pushBack(checkFile);
-
 
387
 
-
 
388
		while (FindNextFile(h, &data))
-
 
389
		{
-
 
390
			std::wstring ws(data.cFileName);
-
 
391
			std::string s(ws.begin(), ws.end());
-
 
392
 
-
 
393
			Utils::String checkFile(s);
-
 
394
			if (checkFile != "." && checkFile != "..")
-
 
395
				files.pushBack(checkFile);
-
 
396
		}
-
 
397
 
-
 
398
		FindClose(h);
-
 
399
		return true;
-
 
400
	}
-
 
401
	return false;
-
 
402
#else
-
 
403
	DIR* dir;
-
 
404
	struct dirent* ent;
-
 
405
	if ((dir = opendir(dir.c_str())) != NULL) {
-
 
406
		while ((ent = readdir(dir)) != NULL) {
-
 
407
			Utils::String checkFile(ent->d_name);
-
 
408
			if (checkFile != "." && checkFile != "..")
-
 
409
				files.pushBack(checkFile);
-
 
410
		}
-
 
411
		closedir(dir);
-
 
412
	}
-
 
413
	return true;
-
 
414
#endif//_WIN32
321
 
415
 
-
 
416
}
-
 
417
 
322
bool CDirIO::dirList(Utils::CStringList &files, Utils::String dir, Utils::String filePattern) const
418
bool CDirIO::dirList(Utils::WStringList& files, const Utils::WString &sDir, const Utils::WString &filePattern) const
323
{
419
{
324
	dir = _parseDir(dir);
420
	Utils::WString dir = _parseDir(sDir);
325
	if ( dir.empty() )
421
	if (dir.empty())
326
		return false;
422
		return false;
327
 
423
 
328
	dir = dir.findReplace("\\", "/");
424
	dir = dir.findReplace(L"\\", L"/");
329
	if (filePattern.empty())
425
	if (filePattern.empty())
330
		dir += "/*";
426
		dir += L"/*";
331
	else
427
	else
332
	{
428
	{
333
		dir += "/";
429
		dir += L"/";
334
		dir += filePattern;
430
		dir += filePattern;
335
	}
431
	}
336
	dir = dir.findReplace("//", "/");
432
	dir = dir.findReplace(L"//", L"/");
337
 
433
 
338
#ifdef _WIN32
434
#ifdef _WIN32
339
	dir = dir.findReplace("/", "\\");
435
	dir = dir.findReplace(L"/", L"\\");
340
 
436
 
341
	WIN32_FIND_DATA data;
437
	WIN32_FIND_DATA data;
342
	TCHAR buf[5000];
-
 
343
	wsprintf(buf, L"%hs", dir.c_str());
-
 
344
 
-
 
345
	HANDLE h = FindFirstFile(buf, &data);
438
	HANDLE h = FindFirstFile(dir.c_str(), &data);
346
	if ( h != INVALID_HANDLE_VALUE)
439
	if (h != INVALID_HANDLE_VALUE)
347
	{
440
	{
348
		std::wstring ws(data.cFileName);
441
		Utils::WString checkFile(data.cFileName);
349
		std::string s(ws.begin(), ws.end());
-
 
350
 
-
 
351
		Utils::String checkFile(s);
-
 
352
		if ( !checkFile.Compare(".") &&amp; !checkFile.Compare(&quot;..") )
442
		if (!checkFile.Compare(L".") &&amp; !checkFile.Compare(L&quot;.."))
353
			files.pushBack(checkFile);
443
			files.pushBack(checkFile);
354
 
444
 
355
		while ( FindNextFile(h, &data) )
445
		while (FindNextFile(h, &data))
356
		{
446
		{
357
			std::wstring ws(data.cFileName);
-
 
358
			std::string s(ws.begin(), ws.end());
-
 
359
 
-
 
360
			Utils::String checkFile(s);
447
			Utils::String checkFile(data.cFileName);
361
			if ( checkFile != "." && checkFile != ".." )
448
			if (checkFile != L"." && checkFile != L"..")
362
				files.pushBack(checkFile);
449
				files.pushBack(checkFile);
363
		}
450
		}
364
 
451
 
365
		FindClose(h);
452
		FindClose(h);
366
		return true;
453
		return true;
367
	}
454
	}
368
	return false;
455
	return false;
369
#else
456
#else
370
	DIR *dir;
457
	DIR* dir;
371
	struct dirent *ent;
458
	struct dirent* ent;
372
	if ((dir = opendir(dir.c_str())) != NULL) {
459
	if ((dir = opendir(dir.c_str())) != NULL) {
373
		while ((ent = readdir(dir)) != NULL) {
460
		while ((ent = readdir(dir)) != NULL) {
374
			Utils::String checkFile(ent->d_name);
461
			Utils::String checkFile(ent->d_name);
375
			if (checkFile != "." && checkFile != "..")
462
			if (checkFile != "." && checkFile != "..")
376
				files.pushBack(checkFile);
463
				files.pushBack(checkFile);
Line 380... Line 467...
380
	return true;
467
	return true;
381
#endif//_WIN32
468
#endif//_WIN32
382
 
469
 
383
}
470
}
384
 
471
 
385
Utils::String CDirIO::file(const Utils::String &filename) const
472
Utils::WString CDirIO::file(const Utils::WString &filename) const
386
{
473
{
387
	if (m_sCurrentDir.empty())
474
	if (m_sCurrentDir.empty())
388
		return filename;
475
		return filename;
389
 
476
 
390
	return m_sCurrentDir + "/" + filename;
477
	return m_sCurrentDir + L"/" + filename;
391
}
478
}
392
 
479
 
393
Utils::String CDirIO::dir(const Utils::String &sDir) const
480
Utils::WString CDirIO::dir(const Utils::WString &sDir) const
394
{
481
{
395
	return _parseDir(sDir);
482
	return _parseDir(sDir);
396
}
483
}
397
 
484
 
398
const Utils::String &CDirIO::dir() const
485
const Utils::WString &CDirIO::dir() const
399
{
486
{
400
	return m_sCurrentDir;
487
	return m_sCurrentDir;
401
}
488
}
402
 
489
 
403
bool CDirIO::cd(const Utils::String &sDir)
490
bool CDirIO::cd(const Utils::WString &sDir)
404
{
491
{
405
	if ( m_sCurrentDir.empty() )
492
	if ( m_sCurrentDir.empty() )
406
		m_sCurrentDir = sDir;
493
		m_sCurrentDir = sDir;
407
	else
494
	else
408
		m_sCurrentDir = m_sCurrentDir + "/" + sDir;
495
		m_sCurrentDir = m_sCurrentDir + L"/" + sDir;
409
	m_sCurrentDir = m_sCurrentDir.asFilename();
496
	m_sCurrentDir = m_sCurrentDir.asFilename();
410
 
497
 
411
	return exists();
498
	return exists();
412
}
499
}
413
 
500
 
414
bool CDirIO::createAndChange(const Utils::String &dir)
501
bool CDirIO::createAndChange(const Utils::WString &dir)
415
{
502
{
416
	if ( create(dir) )
503
	if ( create(dir) )
417
		return cd(dir);
504
		return cd(dir);
418
	return false;
505
	return false;
419
}
506
}
420
 
507
 
421
 
508
 
422
Utils::String CDirIO::topDir() const
509
Utils::WString CDirIO::topDir() const
423
{
510
{
424
	if ( m_sCurrentDir.empty() )
511
	if ( m_sCurrentDir.empty() )
425
		return Utils::String("");
512
		return Utils::WString(L"");
426
 
513
 
427
	return m_sCurrentDir.token("/", -1);
514
	return m_sCurrentDir.token(L"/", -1);
428
}
515
}
429
 
516
 
430
const Utils::String &CDirIO::moveBack()
517
const Utils::WString &CDirIO::moveBack()
431
{
518
{
432
	m_sCurrentDir = m_sCurrentDir.tokens("/", 1, -2);
519
	m_sCurrentDir = m_sCurrentDir.tokens(L"/", 1, -2);
433
	return m_sCurrentDir;
520
	return m_sCurrentDir;
434
}
521
}
435
Utils::String CDirIO::back() const
522
Utils::WString CDirIO::back() const
436
{
523
{
437
	return m_sCurrentDir.tokens("/", 1, -2);
524
	return m_sCurrentDir.tokens(L"/", 1, -2);
438
}
525
}