This commit is contained in:
twinaphex 2020-06-24 22:58:10 +02:00
parent 9d32794a12
commit 57b25033aa
3 changed files with 30 additions and 32 deletions

View File

@ -1371,7 +1371,8 @@ struct string_list* cdrom_get_available_drives(void)
if (!is_cdrom)
continue;
sscanf(dir_list->elems[i].data + strlen("/dev/sg"), "%d", &dev_index);
sscanf(dir_list->elems[i].data + STRLEN_CONST("/dev/sg"),
"%d", &dev_index);
dev_index = '0' + dev_index;
attr.i = dev_index;

View File

@ -129,7 +129,7 @@ static bool m3u_file_load(m3u_file_t *m3u_file)
continue;
/* Determine line 'type' */
m3u_size = strlen(M3U_FILE_NONSTD_LABEL);
m3u_size = STRLEN_CONST(M3U_FILE_NONSTD_LABEL);
/* > '#LABEL:' */
if (!strncmp(
@ -151,12 +151,12 @@ static bool m3u_file_load(m3u_file_t *m3u_file)
/* > '#EXTINF:' */
else if (!strncmp(
line, M3U_FILE_EXTSTD_LABEL,
strlen(M3U_FILE_EXTSTD_LABEL)))
STRLEN_CONST(M3U_FILE_EXTSTD_LABEL)))
{
/* Label is the string to the right
* of the first comma */
const char* label_ptr = strchr(
line + strlen(M3U_FILE_EXTSTD_LABEL),
line + STRLEN_CONST(M3U_FILE_EXTSTD_LABEL),
M3U_FILE_EXTSTD_LABEL_TOKEN);
if (!string_is_empty(label_ptr))

View File

@ -262,47 +262,44 @@ int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, i
libretro_vfs_implementation_file *retro_vfs_file_open_impl(
const char *path, unsigned mode, unsigned hints)
{
int flags = 0;
const char *mode_str = NULL;
libretro_vfs_implementation_file *stream = (libretro_vfs_implementation_file*)
calloc(1, sizeof(*stream));
#if defined(VFS_FRONTEND) || defined(HAVE_CDROM)
int path_len = (int)strlen(path);
#endif
#ifdef VFS_FRONTEND
const char *dumb_prefix = "vfsonly://";
size_t dumb_prefix_siz = strlen(dumb_prefix);
size_t dumb_prefix_siz = STRLEN_CONST("vfsonly://");
int dumb_prefix_len = (int)dumb_prefix_siz;
if (path_len >= dumb_prefix_len)
{
if (!memcmp(path, dumb_prefix, dumb_prefix_len))
path += dumb_prefix_siz;
}
#endif
#ifdef HAVE_CDROM
{
const char *cdrom_prefix = "cdrom://";
size_t cdrom_prefix_siz = strlen(cdrom_prefix);
int cdrom_prefix_len = (int)cdrom_prefix_siz;
if (path_len > cdrom_prefix_len)
{
if (!memcmp(path, cdrom_prefix, cdrom_prefix_len))
{
path += cdrom_prefix_siz;
stream->scheme = VFS_SCHEME_CDROM;
}
}
}
const char *cdrom_prefix = "cdrom://";
size_t cdrom_prefix_siz = STRLEN_CONST("cdrom://");
int cdrom_prefix_len = (int)cdrom_prefix_siz;
#endif
int flags = 0;
const char *mode_str = NULL;
libretro_vfs_implementation_file *stream =
(libretro_vfs_implementation_file*)
calloc(1, sizeof(*stream));
if (!stream)
return NULL;
(void)flags;
#ifdef VFS_FRONTEND
if (path_len >= dumb_prefix_len)
if (!memcmp(path, dumb_prefix, dumb_prefix_len))
path += dumb_prefix_siz;
#endif
#ifdef HAVE_CDROM
if (path_len > cdrom_prefix_len)
{
if (!memcmp(path, cdrom_prefix, cdrom_prefix_len))
{
path += cdrom_prefix_siz;
stream->scheme = VFS_SCHEME_CDROM;
}
}
#endif
stream->hints = hints;
stream->orig_path = strdup(path);