예제 #1
0
파일: service.cpp 프로젝트: st7TEAM/bh-gui
int eServiceCenter::getServiceTypeForExtension(const std::string &str)
{
	return getServiceTypeForExtension(str.c_str());
}
예제 #2
0
RESULT eServiceFS::getContent(std::list<eServiceReference> &list, bool sorted)
{
	DIR *d=opendir(path.c_str());
	if (!d)
		return -errno;

	ePtr<eServiceCenter> sc;
	eServiceCenter::getPrivInstance(sc);

	while (dirent *e=readdir(d))
	{
		if (!(strcmp(e->d_name, ".") && strcmp(e->d_name, "..")))
			continue;
		
		std::string filename;
		
		filename = path;
		filename += e->d_name;
		
		struct stat s;
		if (::stat(filename.c_str(), &s) < 0)
			continue;
		
		if (S_ISDIR(s.st_mode) || S_ISLNK(s.st_mode))
		{
			filename += "/";
			eServiceReference service(eServiceFactoryFS::id, 
				eServiceReference::isDirectory|
				eServiceReference::canDescent|eServiceReference::mustDescent|
				eServiceReference::shouldSort|eServiceReference::sort1,
				filename);
			service.data[0] = 1;
			list.push_back(service);
		} else
		{
			size_t e = filename.rfind('.');
			if (e != std::string::npos && e+1 < filename.length())
			{
				std::string extension = filename.substr(e+1);
				std::transform(extension.begin(), extension.end(), extension.begin(), lower);
				int type = getServiceTypeForExtension(extension);

				if (type == -1)
				{
					type = sc->getServiceTypeForExtension(extension);
				}
			
				if (type != -1)
				{
					eServiceReference service(type,
						0,
						filename);
					service.data[0] = 0;
					list.push_back(service);
				}
			}
		}
	}
	closedir(d);

	if (sorted)
		list.sort(iListableServiceCompare(this));

	return 0;
}
예제 #3
0
int eServiceCenter::getServiceTypeForExtension(const char *str)
{
	return getServiceTypeForExtension(std::string(str));
}