mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-16 17:05:46 -04:00
GameList: Slight optimization to scanning
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include "common/file_system.h"
|
||||
#include "common/iso_reader.h"
|
||||
#include "common/log.h"
|
||||
#include "common/make_array.h"
|
||||
#include "common/state_wrapper.h"
|
||||
#include "common/string_util.h"
|
||||
#include "common/timestamp.h"
|
||||
@ -279,6 +280,26 @@ bool IsM3UFileName(const char* path)
|
||||
return (extension && StringUtil::Strcasecmp(extension, ".m3u") == 0);
|
||||
}
|
||||
|
||||
bool IsLoadableFilename(const char* path)
|
||||
{
|
||||
static constexpr auto extensions = make_array(".bin", ".cue", ".img", ".iso", ".chd", // discs
|
||||
".exe", ".psexe", // exes
|
||||
".psf", ".minipsf", // psf
|
||||
".m3u" // playlists
|
||||
);
|
||||
const char* extension = std::strrchr(path, '.');
|
||||
if (!extension)
|
||||
return false;
|
||||
|
||||
for (const char* test_extension : extensions)
|
||||
{
|
||||
if (StringUtil::Strcasecmp(extension, test_extension) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> ParseM3UFile(const char* path)
|
||||
{
|
||||
std::ifstream ifs(path);
|
||||
|
@ -66,6 +66,9 @@ bool IsPsfFileName(const char* path);
|
||||
/// Returns true if the filename is a M3U Playlist we can handle.
|
||||
bool IsM3UFileName(const char* path);
|
||||
|
||||
/// Returns true if the filename is one we can load.
|
||||
bool IsLoadableFilename(const char* path);
|
||||
|
||||
/// Parses an M3U playlist, returning the entries.
|
||||
std::vector<std::string> ParseM3UFile(const char* path);
|
||||
|
||||
|
Reference in New Issue
Block a user