mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-17 07:50:27 +00:00
Add name generation from id.
This commit is contained in:
parent
3dc5b21b78
commit
2e9fade00a
@ -19,6 +19,7 @@
|
||||
#include "../boolean.h"
|
||||
#include "../libsnes.hpp"
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
const char *ssnes_console_get_rom_ext(void)
|
||||
{
|
||||
@ -46,3 +47,29 @@ const char *ssnes_console_get_rom_ext(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ssnes_console_name_from_id(char *name, size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
const char *id = snes_library_id();
|
||||
if (!id || strlen(id) >= size)
|
||||
{
|
||||
name[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
name[strlen(id)] = '\0';
|
||||
|
||||
for (size_t i = 0; i < size && id[i]; i++)
|
||||
{
|
||||
char c = id[i];
|
||||
if (isspace(c) || isblank(c))
|
||||
name[i] = '_';
|
||||
else if (isupper(c))
|
||||
name[i] = tolower(c);
|
||||
else
|
||||
name[i] = c;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,15 @@
|
||||
#ifndef ROM_EXT_H__
|
||||
#define ROM_EXT_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// Get rom extensions for current library.
|
||||
// Infers info from snes_library_id().
|
||||
// Returns NULL if library doesn't have any preferences in particular.
|
||||
const char *ssnes_console_get_rom_ext(void);
|
||||
|
||||
// Transforms a library id to a name suitable as a pathname.
|
||||
void ssnes_console_name_from_id(char *name, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user