Exemplo n.º 1
0
void _DeleteFolderAndFiles(const char *dirName)
{
	FSString	fsString;

	DIR	*dirp = NULL;
	dirp = opendir(dirName);
	if ( dirp == NULL ) return;
	
	struct dirent *dp;
	while ((dp = readdir(dirp)) != NULL)
	{
	//	printf("%s\n", dp->d_name);
		if ( dp->d_type == DT_REG )
		{
			fsString = dirName;
			fsString.Append(PATH_SEPARATOR_CHAR);
			fsString.Append( dp->d_name);
			
			remove(fsString.GetString());
		}
		else if (dp->d_type == DT_DIR )
		{
			if (strcmp(dp->d_name, ".") == 0 ) continue;
			if (strcmp(dp->d_name, "..") == 0 ) continue;
			
			fsString = dirName;
			fsString.Append(PATH_SEPARATOR_CHAR);
			fsString.Append( dp->d_name);
			
			_DeleteFolderAndFiles(fsString.GetString());
		}
	}
	closedir(dirp);

	rmdir(dirName);
}