Subversion Repositories spk

Rev

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

Rev 160 Rev 183
Line 315... Line 315...
315
			}
315
			}
316
			return true;
316
			return true;
317
		}
317
		}
318
	}
318
	}
319
	return false;
319
	return false;
320
 
-
 
321
}
320
}
322
bool CDirIO::RemoveDir(CyString dir, bool doFiles, bool recursive, CyStringList* errors)
-
 
323
{
-
 
324
	// check if the dir is empty
-
 
325
	Utils::CStringList list;
-
 
326
	if (dirList(list, dir.ToString()))
-
 
327
	{
-
 
328
		if (checkEmptyDir(list))
-
 
329
		{
-
 
330
			Utils::String remDir = _parseDir(dir.ToString());
-
 
331
#ifdef _WIN32
-
 
332
			if (_rmdir(remDir.c_str()) == 0)
-
 
333
#else
-
 
334
			if (rmdir(remDir.c_str()) == 0)
-
 
335
#endif
-
 
336
			{
-
 
337
				if (errors)
-
 
338
					errors->PushBack(CyString(remDir));
-
 
339
			}
-
 
340
			return true;
-
 
341
		}
-
 
342
 
-
 
343
		// not empty
-
 
344
		if (doFiles || recursive)
-
 
345
		{
-
 
346
			for (auto itr = list.begin(); itr != list.end(); itr++)
-
 
347
			{
-
 
348
				Utils::String d = (*itr)->str;
-
 
349
				if (d == "." || d == "..")
-
 
350
					continue;
-
 
351
 
-
 
352
				// if its a file
-
 
353
				Utils::String fullFile = dir.ToString() + "\\" + d;
-
 
354
				if (doFiles && isFile(fullFile))
-
 
355
				{
-
 
356
					Utils::String remFile = _parseDir(fullFile);
-
 
357
					if (remove(remFile.c_str()) == 0)
-
 
358
					{
-
 
359
						if (errors)
-
 
360
							errors->PushBack(CyString(remFile));
-
 
361
					}
-
 
362
				}
-
 
363
				else if (recursive && isDir(fullFile))
-
 
364
					RemoveDir(fullFile, doFiles, recursive, errors);
-
 
365
			}
-
 
366
		}
-
 
367
	}
-
 
368
 
-
 
369
	list.clear();
-
 
370
	if (dirList(list, dir.ToString()))
-
 
371
	{
-
 
372
		if (checkEmptyDir(list))
-
 
373
		{
-
 
374
			Utils::String remDir = _parseDir(dir.ToString());
-
 
375
#ifdef _WIN32
-
 
376
			if (_rmdir(remDir.c_str()) == 0)
-
 
377
#else
-
 
378
			if (rmdir(remDir.c_str()) == 0)
-
 
379
#endif
-
 
380
			{
-
 
381
				if (errors)
-
 
382
					errors->PushBack(CyString(remDir));
-
 
383
			}
-
 
384
			return true;
-
 
385
		}
-
 
386
	}
-
 
387
	return false;
-
 
388
}
-
 
389
 
-
 
390
 
321
 
391
bool CDirIO::dirList(Utils::CStringList &files, Utils::String dir, Utils::String filePattern) const
322
bool CDirIO::dirList(Utils::CStringList &files, Utils::String dir, Utils::String filePattern) const
392
{
323
{
393
	dir = _parseDir(dir);
324
	dir = _parseDir(dir);
394
	if ( dir.empty() )
325
	if ( dir.empty() )