mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 23:55:45 -04:00
GameList: Remove exe/psf extensions from titles in game list
This commit is contained in:
@ -287,6 +287,32 @@ std::string GetPathDirectory(const char* path)
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string_view GetFileNameFromPath(const char* path)
|
||||
{
|
||||
const char* end = path + std::strlen(path);
|
||||
const char* start = std::max(std::strrchr(path, '/'), std::strrchr(path, '\\'));
|
||||
if (!start)
|
||||
return std::string_view(path, end - path);
|
||||
else
|
||||
return std::string_view(start + 1, end - start);
|
||||
}
|
||||
|
||||
std::string_view GetFileTitleFromPath(const char* path)
|
||||
{
|
||||
const char* end = path + std::strlen(path);
|
||||
const char* extension = std::strrchr(path, '.');
|
||||
if (extension && extension > path)
|
||||
end = extension - 1;
|
||||
|
||||
const char* start = std::max(std::strrchr(path, '/'), std::strrchr(path, '\\'));
|
||||
if (!start)
|
||||
return std::string_view(path, end - path);
|
||||
else if (start < end)
|
||||
return std::string_view(start + 1, end - start);
|
||||
else
|
||||
return std::string_view(path);
|
||||
}
|
||||
|
||||
void BuildPathRelativeToFile(char* Destination, u32 cbDestination, const char* CurrentFileName, const char* NewFileName,
|
||||
bool OSPath /* = true */, bool Canonicalize /* = true */)
|
||||
{
|
||||
|
@ -148,6 +148,12 @@ std::string ReplaceExtension(std::string_view path, std::string_view new_extensi
|
||||
/// Returns the directory component of a filename.
|
||||
std::string GetPathDirectory(const char* path);
|
||||
|
||||
/// Returns the filename component of a filename.
|
||||
std::string_view GetFileNameFromPath(const char* path);
|
||||
|
||||
/// Returns the file title (less the extension and path) from a filename.
|
||||
std::string_view GetFileTitleFromPath(const char* path);
|
||||
|
||||
// search for files
|
||||
bool FindFiles(const char* Path, const char* Pattern, u32 Flags, FindResultsArray* pResults);
|
||||
|
||||
|
Reference in New Issue
Block a user