Exemple #1
0
void CFileBrowser::ChangeDir(const std::string & filename, int selection)
{
	std::string newpath;
	if((m_Mode != ModeSC) && (filename == ".."))
	{
		std::string::size_type pos = Path.substr(0,Path.length()-1).rfind('/');

#ifdef ENABLE_MOVIEPLAYER_VLC
		bool is_vlc = (strncmp(Path.c_str(), VLC_URI, strlen(VLC_URI)) == 0);
#endif
		if (pos == std::string::npos)
		{
			newpath = Path;
		}
		else
		{
#ifdef ENABLE_MOVIEPLAYER_VLC
			if (is_vlc && (pos < strlen(VLC_URI) - 1))
				newpath = VLC_URI;
			else
#endif
				newpath = Path.substr(0, pos + 1);
		}

#ifdef ENABLE_MOVIEPLAYER_VLC
		if (strncmp(is_vlc ? &(newpath.c_str()[strlen(VLC_URI)]) : newpath.c_str(), base.c_str(), base.length()) != 0)
			return;
#endif
	}
	else
	{
		newpath=filename;
	}
	if(m_Mode != ModeSC && (newpath.rfind('/') != newpath.length()-1 || newpath.length() == 0))
	{
		newpath += '/';
	}
	filelist.clear();
	Path = newpath;
	name = newpath;
	CFileList allfiles;
	readDir(newpath, &allfiles);
	// filter
	CFileList::iterator file = allfiles.begin();
	for(; file != allfiles.end() ; file++)
	{
		if(Filter != NULL && (!S_ISDIR(file->Mode)) && use_filter)
		{
			if(!Filter->matchFilter(file->Name))
			{
				continue;
			}
			if(Hide_records) {
				int ext_pos = file->Name.rfind('.');
				if( ext_pos > 0) {
					std::string extension = file->Name.substr(ext_pos + 1, name.length() - ext_pos);
					if(strcasecmp(extension.c_str(), "ts") == 0) {
						std::string fname = file->Name.substr(0, ext_pos) + ".xml";
						if(access(fname.c_str(), F_OK) == 0)
							continue;
					}
				}
			}
		}
		if(Dir_Mode && (!S_ISDIR(file->Mode)))
		{
			continue;
		}
		filelist.push_back(*file);
	}
	// sort result
	sort(filelist.begin(), filelist.end(), sortBy[g_settings.filebrowser_sortmethod]);

	selected = 0;
	if ((selection != -1) && (selection < (int)filelist.size()))
		selected = selection;
	paintHead();
	paint();
}
Exemple #2
0
void CFileBrowser::ChangeDir(const std::string& filename, int selection)
{
	dprintf(DEBUG_INFO, "CFileBrowser::ChangeDir %s\n", filename.c_str());

	std::string newpath;
	
	if((filename == ".."))
	{
		std::string::size_type pos = Path.substr(0, Path.length()-1).rfind('/');

		if (pos == std::string::npos)
		{
			newpath = Path;
		}
		else
		{
			newpath = Path.substr(0, pos + 1);
		}

		if (strncmp(newpath.c_str(), base.c_str(), base.length()) != 0)
			return;
	}
	else
	{
		newpath = filename;
	}
	
	if((newpath.rfind('/') != newpath.length()-1 || newpath.length() == 0))
	{
		newpath += '/';
	}
	
	Path = newpath;
	name = newpath;
	
	CFileList allfiles;
	
	readDir(newpath, &allfiles);

	filelist.clear();
	
	// filter
	CFileList::iterator file = allfiles.begin();
	for(; file != allfiles.end() ; file++)
	{
		if(Filter != NULL && (!S_ISDIR(file->Mode)) && use_filter)
		{
			if(!Filter->matchFilter(file->Name))
			{
				continue;
			}
			
			// ts filter
			if(Hide_records) 
			{
				int ext_pos = file->Name.rfind('.');
				if( ext_pos > 0) 
				{
					std::string extension = file->Name.substr(ext_pos + 1, name.length() - ext_pos);
					if(strcasecmp(extension.c_str(), "ts") == 0) 
					{
						std::string fname = file->Name.substr(0, ext_pos) + ".xml";
						if(access(fname.c_str(), F_OK) == 0)
							continue;
					}
				}
			}
		}
		
		if(Dir_Mode && (!S_ISDIR(file->Mode)))
		{
			continue;
		}
		
		filelist.push_back(*file);
	}
	
	// sort result
	sort(filelist.begin(), filelist.end(), sortBy[g_settings.filebrowser_sortmethod]);

	selected = 0;
	if ((selection != -1) && (selection < (int)filelist.size()))
		selected = selection;
	
	paintHead();
	paint();
}