2015-09-16 20:39:47 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2014-2017 - Jean-André Santoni
|
2019-02-22 21:31:54 +00:00
|
|
|
* Copyright (C) 2016-2019 - Brad Parker
|
2015-09-16 20:39:47 +00:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
2015-09-25 23:44:47 +00:00
|
|
|
#include <ctype.h>
|
2017-04-23 10:17:51 +00:00
|
|
|
#include <string.h>
|
2015-09-16 20:39:47 +00:00
|
|
|
|
2016-09-11 14:31:23 +00:00
|
|
|
#include <retro_miscellaneous.h>
|
2020-04-21 02:16:55 +00:00
|
|
|
#include <retro_endianness.h>
|
2015-09-16 20:39:47 +00:00
|
|
|
#include <compat/strcasestr.h>
|
|
|
|
#include <compat/strl.h>
|
2016-02-07 00:50:08 +00:00
|
|
|
#include <file/file_path.h>
|
2015-09-16 20:39:47 +00:00
|
|
|
#include <retro_endianness.h>
|
2016-03-20 15:29:14 +00:00
|
|
|
#include <streams/file_stream.h>
|
2017-09-17 05:31:58 +00:00
|
|
|
#include <streams/interface_stream.h>
|
2016-01-20 03:07:24 +00:00
|
|
|
#include <string/stdstring.h>
|
2015-09-16 20:39:47 +00:00
|
|
|
|
2016-09-11 14:24:02 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
2015-09-16 20:39:47 +00:00
|
|
|
|
|
|
|
#include "../database_info.h"
|
|
|
|
|
2016-09-11 14:24:02 +00:00
|
|
|
#include "tasks_internal.h"
|
|
|
|
|
2016-03-20 16:28:24 +00:00
|
|
|
#include "../list_special.h"
|
2015-09-16 20:39:47 +00:00
|
|
|
#include "../msg_hash.h"
|
2015-11-23 11:03:38 +00:00
|
|
|
#include "../verbosity.h"
|
2015-09-16 20:39:47 +00:00
|
|
|
|
2016-09-01 03:53:28 +00:00
|
|
|
#define MAGIC_LEN 17
|
2016-01-28 08:33:09 +00:00
|
|
|
#define MAX_TOKEN_LEN 255
|
2015-09-16 20:39:47 +00:00
|
|
|
|
2016-02-04 09:30:12 +00:00
|
|
|
#ifdef MSB_FIRST
|
|
|
|
#define MODETEST_VAL 0x00ffffff
|
|
|
|
#else
|
|
|
|
#define MODETEST_VAL 0xffffff00
|
|
|
|
#endif
|
|
|
|
|
2015-09-16 20:39:47 +00:00
|
|
|
struct magic_entry
|
|
|
|
{
|
2017-03-07 00:16:26 +00:00
|
|
|
int32_t offset;
|
|
|
|
const char *system_name;
|
|
|
|
const char *magic;
|
2015-09-16 20:39:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct magic_entry MAGIC_NUMBERS[] = {
|
2017-03-07 00:16:26 +00:00
|
|
|
{ 0, "ps1", "\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x02\x00\x02\x00"},
|
|
|
|
{ 0x838840, "pcecd", "\x82\xb1\x82\xcc\x83\x76\x83\x8d\x83\x4f\x83\x89\x83\x80\x82\xcc\x92"},
|
|
|
|
{ 0, "scd", "\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x02\x00\x01\x53"},
|
2017-10-27 07:30:12 +00:00
|
|
|
{ 0x000400, "gc", "\x00\x01\xC7\x04\x80\x28\x00\x60\x00\x00\x00\x00\x00\x00\x00\x00\x00"},
|
2017-03-07 00:16:26 +00:00
|
|
|
{ 0, NULL, NULL}
|
2015-09-16 20:39:47 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 22:18:11 +00:00
|
|
|
static int64_t get_token(intfstream_t *fd, char *token, uint64_t max_len)
|
2015-09-16 20:39:47 +00:00
|
|
|
{
|
|
|
|
char *c = token;
|
2018-04-12 22:18:11 +00:00
|
|
|
int64_t len = 0;
|
2015-09-16 20:39:47 +00:00
|
|
|
int in_string = 0;
|
|
|
|
|
2020-01-30 15:15:52 +00:00
|
|
|
for (;;)
|
2015-09-16 20:39:47 +00:00
|
|
|
{
|
2018-04-12 22:18:11 +00:00
|
|
|
int64_t rv = (int64_t)intfstream_read(fd, c, 1);
|
2015-09-16 20:39:47 +00:00
|
|
|
if (rv == 0)
|
|
|
|
return 0;
|
2015-09-18 02:03:11 +00:00
|
|
|
|
|
|
|
if (rv < 1)
|
2015-09-16 20:39:47 +00:00
|
|
|
{
|
|
|
|
switch (errno)
|
|
|
|
{
|
|
|
|
case EINTR:
|
|
|
|
case EAGAIN:
|
|
|
|
continue;
|
|
|
|
default:
|
|
|
|
return -errno;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (*c)
|
|
|
|
{
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\r':
|
|
|
|
case '\n':
|
|
|
|
if (c == token)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!in_string)
|
|
|
|
{
|
|
|
|
*c = '\0';
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '\"':
|
|
|
|
if (c == token)
|
|
|
|
{
|
|
|
|
in_string = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
*c = '\0';
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
len++;
|
|
|
|
c++;
|
2018-04-12 22:18:11 +00:00
|
|
|
if (len == (int64_t)max_len)
|
2015-09-16 20:39:47 +00:00
|
|
|
{
|
|
|
|
*c = '\0';
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-17 05:31:58 +00:00
|
|
|
static int detect_ps1_game_sub(intfstream_t *fp,
|
2016-02-03 16:41:04 +00:00
|
|
|
char *game_id, int sub_channel_mixed)
|
2015-09-25 22:05:15 +00:00
|
|
|
{
|
|
|
|
uint8_t* tmp;
|
2016-06-03 09:46:55 +00:00
|
|
|
uint8_t* boot_file;
|
2020-03-07 18:14:45 +00:00
|
|
|
int skip, frame_size, cd_sector;
|
2016-10-15 23:31:06 +00:00
|
|
|
uint8_t buffer[2048 * 2];
|
2020-03-07 18:14:45 +00:00
|
|
|
int is_mode1 = 0;
|
2015-09-25 22:05:15 +00:00
|
|
|
|
2020-03-07 18:14:45 +00:00
|
|
|
buffer[0] = '\0';
|
2017-09-26 01:51:50 +00:00
|
|
|
|
|
|
|
if (intfstream_seek(fp, 0, SEEK_END) == -1)
|
2020-03-01 20:57:57 +00:00
|
|
|
return 0;
|
2015-09-25 22:05:15 +00:00
|
|
|
|
|
|
|
if (!sub_channel_mixed)
|
|
|
|
{
|
2017-09-17 05:31:58 +00:00
|
|
|
if (!(intfstream_tell(fp) & 0x7FF))
|
2015-09-25 22:05:15 +00:00
|
|
|
{
|
|
|
|
unsigned int mode_test = 0;
|
|
|
|
|
2017-09-26 01:51:50 +00:00
|
|
|
if (intfstream_seek(fp, 0, SEEK_SET) == -1)
|
2020-03-01 20:57:57 +00:00
|
|
|
return 0;
|
2017-09-26 01:51:50 +00:00
|
|
|
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_read(fp, &mode_test, 4);
|
2015-09-27 23:52:56 +00:00
|
|
|
if (mode_test != MODETEST_VAL)
|
|
|
|
is_mode1 = 1;
|
2015-09-25 22:05:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
skip = is_mode1? 0: 24;
|
|
|
|
frame_size = sub_channel_mixed? 2448: is_mode1? 2048: 2352;
|
|
|
|
|
2017-09-26 01:51:50 +00:00
|
|
|
if (intfstream_seek(fp, 156 + skip + 16 * frame_size, SEEK_SET) == -1)
|
2020-03-01 20:57:57 +00:00
|
|
|
return 0;
|
2017-09-26 01:51:50 +00:00
|
|
|
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_read(fp, buffer, 6);
|
2015-09-25 22:05:15 +00:00
|
|
|
|
|
|
|
cd_sector = buffer[2] | (buffer[3] << 8) | (buffer[4] << 16);
|
2017-09-26 01:51:50 +00:00
|
|
|
|
|
|
|
if (intfstream_seek(fp, skip + cd_sector * frame_size, SEEK_SET) == -1)
|
2020-03-01 20:57:57 +00:00
|
|
|
return 0;
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_read(fp, buffer, 2048 * 2);
|
2015-09-25 22:05:15 +00:00
|
|
|
|
|
|
|
tmp = buffer;
|
|
|
|
while (tmp < (buffer + 2048 * 2))
|
|
|
|
{
|
|
|
|
if (!*tmp)
|
2020-03-01 20:57:57 +00:00
|
|
|
return 0;
|
2015-09-25 22:05:15 +00:00
|
|
|
|
|
|
|
if (!strncasecmp((const char*)(tmp + 33), "SYSTEM.CNF;1", 12))
|
|
|
|
break;
|
|
|
|
|
|
|
|
tmp += *tmp;
|
|
|
|
}
|
2016-05-26 15:34:44 +00:00
|
|
|
|
2020-03-01 20:57:57 +00:00
|
|
|
if (tmp >= (buffer + 2048 * 2))
|
|
|
|
return 0;
|
2015-09-25 22:05:15 +00:00
|
|
|
|
|
|
|
cd_sector = tmp[2] | (tmp[3] << 8) | (tmp[4] << 16);
|
2017-09-26 01:51:50 +00:00
|
|
|
if (intfstream_seek(fp, skip + cd_sector * frame_size, SEEK_SET) == -1)
|
2020-03-01 20:57:57 +00:00
|
|
|
return 0;
|
2017-09-26 01:51:50 +00:00
|
|
|
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_read(fp, buffer, 256);
|
2016-06-03 19:06:13 +00:00
|
|
|
buffer[256] = '\0';
|
2016-06-03 09:46:55 +00:00
|
|
|
|
|
|
|
tmp = buffer;
|
2016-06-03 19:06:13 +00:00
|
|
|
while(*tmp && strncasecmp((const char*)tmp, "boot", 4))
|
|
|
|
tmp++;
|
|
|
|
|
2020-03-01 20:57:57 +00:00
|
|
|
if (!*tmp)
|
|
|
|
return 0;
|
2016-06-03 09:46:55 +00:00
|
|
|
|
2016-06-03 19:06:13 +00:00
|
|
|
boot_file = tmp;
|
2016-06-03 09:46:55 +00:00
|
|
|
while(*tmp && *tmp != '\n')
|
|
|
|
{
|
2020-03-01 20:57:57 +00:00
|
|
|
if ((*tmp == '\\') || (*tmp == ':'))
|
2016-06-03 09:46:55 +00:00
|
|
|
boot_file = tmp + 1;
|
2015-09-25 22:05:15 +00:00
|
|
|
|
|
|
|
tmp++;
|
2016-06-03 09:46:55 +00:00
|
|
|
}
|
2015-09-25 22:05:15 +00:00
|
|
|
|
2016-06-03 09:46:55 +00:00
|
|
|
tmp = boot_file;
|
2015-09-25 23:44:47 +00:00
|
|
|
*game_id++ = toupper(*tmp++);
|
|
|
|
*game_id++ = toupper(*tmp++);
|
|
|
|
*game_id++ = toupper(*tmp++);
|
|
|
|
*game_id++ = toupper(*tmp++);
|
2016-06-03 10:36:48 +00:00
|
|
|
*game_id++ = '-';
|
|
|
|
|
2020-03-01 20:57:57 +00:00
|
|
|
if (!isalnum(*tmp))
|
2016-06-03 10:36:48 +00:00
|
|
|
tmp++;
|
|
|
|
|
|
|
|
while(isalnum(*tmp))
|
2016-06-03 09:46:55 +00:00
|
|
|
{
|
2016-06-03 10:36:48 +00:00
|
|
|
*game_id++ = *tmp++;
|
2020-03-01 20:57:57 +00:00
|
|
|
if (*tmp == '.')
|
2016-06-03 09:46:55 +00:00
|
|
|
tmp++;
|
|
|
|
}
|
2016-06-03 10:36:48 +00:00
|
|
|
|
2015-09-25 22:05:15 +00:00
|
|
|
*game_id = 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-09-17 05:31:58 +00:00
|
|
|
int detect_ps1_game(intfstream_t *fd, char *game_id)
|
2015-09-25 22:05:15 +00:00
|
|
|
{
|
2017-09-17 05:31:58 +00:00
|
|
|
if (detect_ps1_game_sub(fd, game_id, 0))
|
2015-09-25 22:05:15 +00:00
|
|
|
return 1;
|
|
|
|
|
2017-09-17 05:31:58 +00:00
|
|
|
return detect_ps1_game_sub(fd, game_id, 1);
|
2015-09-25 22:05:15 +00:00
|
|
|
}
|
2015-09-16 20:39:47 +00:00
|
|
|
|
2017-09-17 05:31:58 +00:00
|
|
|
int detect_psp_game(intfstream_t *fd, char *game_id)
|
2015-09-26 22:12:17 +00:00
|
|
|
{
|
|
|
|
unsigned pos;
|
2016-03-24 03:09:25 +00:00
|
|
|
bool rv = false;
|
2015-09-26 22:12:17 +00:00
|
|
|
|
|
|
|
for (pos = 0; pos < 100000; pos++)
|
|
|
|
{
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_seek(fd, pos, SEEK_SET);
|
2015-09-26 22:12:17 +00:00
|
|
|
|
2017-09-17 05:31:58 +00:00
|
|
|
if (intfstream_read(fd, game_id, 5) > 0)
|
2015-09-26 22:12:17 +00:00
|
|
|
{
|
2019-04-29 02:04:33 +00:00
|
|
|
game_id[5] = '\0';
|
2017-05-28 16:07:00 +00:00
|
|
|
|
2017-06-06 07:46:13 +00:00
|
|
|
if (
|
2019-04-29 02:04:33 +00:00
|
|
|
(string_is_equal(game_id, "ULES-"))
|
|
|
|
|| (string_is_equal(game_id, "ULUS-"))
|
|
|
|
|| (string_is_equal(game_id, "ULJS-"))
|
|
|
|
|
|
|
|
|| (string_is_equal(game_id, "ULEM-"))
|
|
|
|
|| (string_is_equal(game_id, "ULUM-"))
|
|
|
|
|| (string_is_equal(game_id, "ULJM-"))
|
|
|
|
|
|
|
|
|| (string_is_equal(game_id, "UCES-"))
|
|
|
|
|| (string_is_equal(game_id, "UCUS-"))
|
|
|
|
|| (string_is_equal(game_id, "UCJS-"))
|
|
|
|
|| (string_is_equal(game_id, "UCAS-"))
|
2020-03-13 01:19:32 +00:00
|
|
|
|| (string_is_equal(game_id, "UCKS-"))
|
2019-04-29 02:04:33 +00:00
|
|
|
|
2020-03-10 02:46:30 +00:00
|
|
|
|| (string_is_equal(game_id, "ULKS-"))
|
|
|
|
|| (string_is_equal(game_id, "ULAS-"))
|
|
|
|
|
2019-04-29 02:04:33 +00:00
|
|
|
|| (string_is_equal(game_id, "NPEH-"))
|
|
|
|
|| (string_is_equal(game_id, "NPUH-"))
|
|
|
|
|| (string_is_equal(game_id, "NPJH-"))
|
|
|
|
|
|
|
|
|| (string_is_equal(game_id, "NPEG-"))
|
|
|
|
|| (string_is_equal(game_id, "NPUG-"))
|
|
|
|
|| (string_is_equal(game_id, "NPJG-"))
|
|
|
|
|| (string_is_equal(game_id, "NPHG-"))
|
|
|
|
|
|
|
|
|| (string_is_equal(game_id, "NPEZ-"))
|
|
|
|
|| (string_is_equal(game_id, "NPUZ-"))
|
|
|
|
|| (string_is_equal(game_id, "NPJZ-"))
|
2017-06-06 07:46:13 +00:00
|
|
|
)
|
|
|
|
{
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_seek(fd, pos, SEEK_SET);
|
|
|
|
if (intfstream_read(fd, game_id, 10) > 0)
|
2017-05-28 16:07:00 +00:00
|
|
|
{
|
2019-04-29 02:04:33 +00:00
|
|
|
#if 0
|
|
|
|
game_id[4] = '-';
|
|
|
|
game_id[8] = game_id[9];
|
|
|
|
game_id[9] = game_id[10];
|
|
|
|
#endif
|
2017-06-06 07:46:13 +00:00
|
|
|
game_id[10] = '\0';
|
|
|
|
rv = true;
|
2017-05-28 16:07:00 +00:00
|
|
|
}
|
2017-06-06 07:46:13 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-09-26 22:12:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2017-10-27 07:58:19 +00:00
|
|
|
int detect_gc_game(intfstream_t *fd, char *game_id)
|
|
|
|
{
|
|
|
|
bool rv = false;
|
|
|
|
|
|
|
|
intfstream_seek(fd, 0, SEEK_SET);
|
|
|
|
|
|
|
|
if (intfstream_read(fd, game_id, 6) > 0)
|
|
|
|
{
|
|
|
|
game_id[6] = '\0';
|
|
|
|
rv = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2017-07-30 03:23:05 +00:00
|
|
|
/**
|
|
|
|
* Check for an ASCII serial in the first few bits of the ISO (Wii).
|
|
|
|
*/
|
2017-09-17 05:31:58 +00:00
|
|
|
int detect_serial_ascii_game(intfstream_t *fd, char *game_id)
|
2017-07-30 03:23:05 +00:00
|
|
|
{
|
|
|
|
unsigned pos;
|
2020-06-10 14:24:52 +00:00
|
|
|
int number_of_ascii = 0;
|
|
|
|
bool rv = false;
|
2017-07-30 03:23:05 +00:00
|
|
|
|
|
|
|
for (pos = 0; pos < 10000; pos++)
|
|
|
|
{
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_seek(fd, pos, SEEK_SET);
|
|
|
|
if (intfstream_read(fd, game_id, 15) > 0)
|
2017-07-30 03:23:05 +00:00
|
|
|
{
|
2017-07-30 08:11:41 +00:00
|
|
|
unsigned i;
|
2020-06-10 14:24:52 +00:00
|
|
|
game_id[15] = '\0';
|
|
|
|
number_of_ascii = 0;
|
2017-07-30 03:23:05 +00:00
|
|
|
|
2019-04-29 02:04:33 +00:00
|
|
|
/* When scanning WBFS files, "WBFS" is discovered as the first serial. Ignore it. */
|
2020-06-10 14:24:52 +00:00
|
|
|
if (string_is_equal(game_id, "WBFS"))
|
2018-04-29 13:51:38 +00:00
|
|
|
continue;
|
|
|
|
|
2017-07-30 08:11:41 +00:00
|
|
|
/* Loop through until we run out of ASCII characters. */
|
|
|
|
for (i = 0; i < 15; i++)
|
|
|
|
{
|
|
|
|
/* Is the given character ASCII? A-Z, 0-9, - */
|
2020-06-10 14:24:52 +00:00
|
|
|
if ( (game_id[i] == 45) ||
|
|
|
|
(game_id[i] >= 48 && game_id[i] <= 57) ||
|
|
|
|
(game_id[i] >= 65 && game_id[i] <= 90))
|
|
|
|
number_of_ascii++;
|
2017-07-30 08:11:41 +00:00
|
|
|
else
|
2017-07-30 03:23:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-10 14:24:52 +00:00
|
|
|
/* If the length of the text is between 3 and 9 characters,
|
|
|
|
* it could be a serial. */
|
|
|
|
if (number_of_ascii > 3 && number_of_ascii < 9)
|
2017-07-30 08:11:41 +00:00
|
|
|
{
|
|
|
|
/* Cut the string off, and return it as a valid serial. */
|
2020-06-10 14:24:52 +00:00
|
|
|
game_id[number_of_ascii] = '\0';
|
|
|
|
rv = true;
|
2017-07-30 03:23:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2017-09-17 05:31:58 +00:00
|
|
|
int detect_system(intfstream_t *fd, const char **system_name)
|
2015-09-16 20:39:47 +00:00
|
|
|
{
|
|
|
|
int i;
|
2020-06-10 14:24:52 +00:00
|
|
|
int rv;
|
2018-04-12 22:18:11 +00:00
|
|
|
int64_t read;
|
2020-06-10 14:24:52 +00:00
|
|
|
char magic[MAGIC_LEN];
|
2015-09-16 20:39:47 +00:00
|
|
|
|
|
|
|
for (i = 0; MAGIC_NUMBERS[i].system_name != NULL; i++)
|
|
|
|
{
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_seek(fd, MAGIC_NUMBERS[i].offset, SEEK_SET);
|
2017-05-28 16:07:00 +00:00
|
|
|
|
2017-09-21 04:21:44 +00:00
|
|
|
read = intfstream_read(fd, magic, MAGIC_LEN);
|
2020-06-10 14:24:52 +00:00
|
|
|
|
2017-09-21 04:21:44 +00:00
|
|
|
if (read < 0)
|
2017-03-07 00:16:26 +00:00
|
|
|
{
|
2017-09-17 05:31:58 +00:00
|
|
|
RARCH_LOG("Could not read data at offset %d: %s\n",
|
|
|
|
MAGIC_NUMBERS[i].offset, strerror(errno));
|
2017-03-07 00:16:26 +00:00
|
|
|
rv = -errno;
|
|
|
|
goto clean;
|
|
|
|
}
|
|
|
|
|
2017-09-21 04:21:44 +00:00
|
|
|
if (read < MAGIC_LEN)
|
|
|
|
continue;
|
|
|
|
|
2018-04-11 00:37:35 +00:00
|
|
|
if (memcmp(MAGIC_NUMBERS[i].magic, magic, MAGIC_LEN) == 0)
|
2015-09-16 20:39:47 +00:00
|
|
|
{
|
|
|
|
*system_name = MAGIC_NUMBERS[i].system_name;
|
|
|
|
rv = 0;
|
|
|
|
goto clean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_seek(fd, 0x8008, SEEK_SET);
|
|
|
|
if (intfstream_read(fd, magic, 8) > 0)
|
2015-09-27 00:14:24 +00:00
|
|
|
{
|
|
|
|
magic[8] = '\0';
|
2017-05-28 16:07:00 +00:00
|
|
|
if (!string_is_empty(magic) &&
|
2019-04-29 02:04:33 +00:00
|
|
|
string_is_equal(magic, "PSP GAME"))
|
2015-09-27 00:14:24 +00:00
|
|
|
{
|
|
|
|
*system_name = "psp\0";
|
|
|
|
rv = 0;
|
|
|
|
goto clean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-30 03:58:05 +00:00
|
|
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_COULD_NOT_FIND_COMPATIBLE_SYSTEM));
|
2015-09-16 20:39:47 +00:00
|
|
|
rv = -EINVAL;
|
2016-06-05 16:32:26 +00:00
|
|
|
|
2015-09-16 20:39:47 +00:00
|
|
|
clean:
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2018-04-12 22:18:11 +00:00
|
|
|
static int64_t intfstream_get_file_size(const char *path)
|
2017-09-17 21:26:06 +00:00
|
|
|
{
|
2018-04-12 22:18:11 +00:00
|
|
|
int64_t rv;
|
2017-12-11 12:21:44 +00:00
|
|
|
intfstream_t *fd = intfstream_open_file(path,
|
2017-12-11 11:53:47 +00:00
|
|
|
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
2017-12-11 12:21:44 +00:00
|
|
|
if (!fd)
|
2017-09-17 21:26:06 +00:00
|
|
|
return -1;
|
2017-12-11 12:21:44 +00:00
|
|
|
rv = intfstream_get_size(fd);
|
|
|
|
intfstream_close(fd);
|
2017-12-11 19:24:00 +00:00
|
|
|
free(fd);
|
2017-09-17 21:26:06 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2018-04-12 22:18:11 +00:00
|
|
|
static bool update_cand(int64_t *cand_index, int64_t *last_index,
|
2020-06-10 14:24:52 +00:00
|
|
|
uint64_t *largest, char *last_file, uint64_t *offset,
|
|
|
|
uint64_t *size, char *track_path, uint64_t max_len)
|
2017-09-17 21:26:06 +00:00
|
|
|
{
|
2018-04-09 17:30:36 +00:00
|
|
|
if (*cand_index != -1)
|
|
|
|
{
|
2018-04-12 22:18:11 +00:00
|
|
|
if ((uint64_t)(*last_index - *cand_index) > *largest)
|
2018-04-09 17:30:36 +00:00
|
|
|
{
|
|
|
|
*largest = *last_index - *cand_index;
|
2018-04-12 22:47:42 +00:00
|
|
|
strlcpy(track_path, last_file, (size_t)max_len);
|
2018-04-09 17:30:36 +00:00
|
|
|
*offset = *cand_index;
|
|
|
|
*size = *largest;
|
|
|
|
*cand_index = -1;
|
|
|
|
return true;
|
|
|
|
}
|
2020-06-10 14:24:52 +00:00
|
|
|
*cand_index = -1;
|
2018-04-09 17:30:36 +00:00
|
|
|
}
|
|
|
|
return false;
|
2017-09-17 21:26:06 +00:00
|
|
|
}
|
|
|
|
|
2017-09-18 00:39:41 +00:00
|
|
|
int cue_find_track(const char *cue_path, bool first,
|
2018-04-12 22:18:11 +00:00
|
|
|
uint64_t *offset, uint64_t *size, char *track_path, uint64_t max_len)
|
2015-09-16 20:39:47 +00:00
|
|
|
{
|
2016-06-30 04:02:30 +00:00
|
|
|
int rv;
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_info_t info;
|
2017-09-19 19:29:28 +00:00
|
|
|
char *tmp_token = (char*)malloc(MAX_TOKEN_LEN);
|
|
|
|
char *last_file = (char*)malloc(PATH_MAX_LENGTH + 1);
|
|
|
|
intfstream_t *fd = NULL;
|
2018-04-12 22:18:11 +00:00
|
|
|
int64_t last_index = -1;
|
|
|
|
int64_t cand_index = -1;
|
2017-09-19 19:29:28 +00:00
|
|
|
int32_t cand_track = -1;
|
|
|
|
int32_t track = 0;
|
2018-04-12 22:18:11 +00:00
|
|
|
uint64_t largest = 0;
|
|
|
|
int64_t volatile file_size = -1;
|
2017-09-19 19:29:28 +00:00
|
|
|
bool is_data = false;
|
|
|
|
char *cue_dir = (char*)malloc(PATH_MAX_LENGTH);
|
|
|
|
cue_dir[0] = '\0';
|
2017-09-18 00:46:02 +00:00
|
|
|
|
|
|
|
fill_pathname_basedir(cue_dir, cue_path, PATH_MAX_LENGTH);
|
2017-09-17 05:31:58 +00:00
|
|
|
|
2020-06-10 14:24:52 +00:00
|
|
|
info.type = INTFSTREAM_FILE;
|
|
|
|
fd = (intfstream_t*)intfstream_init(&info);
|
2015-09-16 20:39:47 +00:00
|
|
|
|
2015-09-17 18:31:04 +00:00
|
|
|
if (!fd)
|
2017-09-17 17:14:51 +00:00
|
|
|
goto error;
|
2017-09-17 05:31:58 +00:00
|
|
|
|
2017-12-11 11:15:00 +00:00
|
|
|
if (!intfstream_open(fd, cue_path,
|
2017-12-11 11:53:47 +00:00
|
|
|
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE))
|
2015-09-16 20:39:47 +00:00
|
|
|
{
|
|
|
|
RARCH_LOG("Could not open CUE file '%s': %s\n", cue_path,
|
|
|
|
strerror(errno));
|
2017-09-12 03:04:27 +00:00
|
|
|
goto error;
|
2015-09-16 20:39:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RARCH_LOG("Parsing CUE file '%s'...\n", cue_path);
|
|
|
|
|
2016-10-09 07:56:03 +00:00
|
|
|
tmp_token[0] = '\0';
|
|
|
|
|
2017-09-17 21:26:06 +00:00
|
|
|
rv = -EINVAL;
|
|
|
|
|
2015-09-16 20:39:47 +00:00
|
|
|
while (get_token(fd, tmp_token, MAX_TOKEN_LEN) > 0)
|
|
|
|
{
|
2019-08-01 23:16:18 +00:00
|
|
|
if (string_is_equal_noncase(tmp_token, "FILE"))
|
2015-09-16 20:39:47 +00:00
|
|
|
{
|
2017-09-17 21:26:06 +00:00
|
|
|
/* Set last index to last EOF */
|
2018-04-09 17:30:36 +00:00
|
|
|
if (file_size != -1)
|
2017-09-17 21:26:06 +00:00
|
|
|
last_index = file_size;
|
|
|
|
|
|
|
|
/* We're changing files since the candidate, update it */
|
2020-06-10 14:24:52 +00:00
|
|
|
if (update_cand(&cand_index, &last_index,
|
|
|
|
&largest, last_file, offset,
|
|
|
|
size, track_path, max_len))
|
2018-04-09 17:30:36 +00:00
|
|
|
{
|
2017-09-17 21:26:06 +00:00
|
|
|
rv = 0;
|
2018-04-09 17:30:36 +00:00
|
|
|
if (first)
|
2017-09-17 21:26:06 +00:00
|
|
|
goto clean;
|
|
|
|
}
|
|
|
|
|
2017-06-06 08:20:34 +00:00
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
2020-06-10 14:24:52 +00:00
|
|
|
fill_pathname_join(last_file, cue_dir,
|
|
|
|
tmp_token, PATH_MAX_LENGTH);
|
2017-09-17 21:26:06 +00:00
|
|
|
|
2017-12-11 12:21:44 +00:00
|
|
|
file_size = intfstream_get_file_size(last_file);
|
2015-09-16 20:39:47 +00:00
|
|
|
|
2017-09-17 21:26:06 +00:00
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
|
|
|
|
2017-06-06 08:20:34 +00:00
|
|
|
}
|
2019-08-01 23:16:18 +00:00
|
|
|
else if (string_is_equal_noncase(tmp_token, "TRACK"))
|
2017-06-06 08:20:34 +00:00
|
|
|
{
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
2019-08-01 23:16:18 +00:00
|
|
|
is_data = !string_is_equal_noncase(tmp_token, "AUDIO");
|
2017-09-17 21:26:06 +00:00
|
|
|
++track;
|
2018-04-09 17:30:36 +00:00
|
|
|
}
|
2019-08-01 23:16:18 +00:00
|
|
|
else if (string_is_equal_noncase(tmp_token, "INDEX"))
|
2018-04-09 17:30:36 +00:00
|
|
|
{
|
2017-09-17 21:26:06 +00:00
|
|
|
int m, s, f;
|
2017-06-06 08:20:34 +00:00
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
2016-01-20 16:34:19 +00:00
|
|
|
|
2017-06-06 08:20:34 +00:00
|
|
|
if (sscanf(tmp_token, "%02d:%02d:%02d", &m, &s, &f) < 3)
|
|
|
|
{
|
|
|
|
RARCH_LOG("Error parsing time stamp '%s'\n", tmp_token);
|
2017-09-12 03:04:27 +00:00
|
|
|
goto error;
|
2017-06-06 08:20:34 +00:00
|
|
|
}
|
2016-01-20 16:34:19 +00:00
|
|
|
|
2017-09-17 21:26:06 +00:00
|
|
|
last_index = (size_t) (((m * 60 + s) * 75) + f) * 2352;
|
2015-09-16 20:39:47 +00:00
|
|
|
|
2017-09-17 21:26:06 +00:00
|
|
|
/* If we've changed tracks since the candidate, update it */
|
|
|
|
if (cand_track != -1 && track != cand_track &&
|
2020-06-10 14:24:52 +00:00
|
|
|
update_cand(&cand_index, &last_index, &largest,
|
|
|
|
last_file, offset,
|
|
|
|
size, track_path, max_len))
|
2018-04-09 17:30:36 +00:00
|
|
|
{
|
2017-09-17 21:26:06 +00:00
|
|
|
rv = 0;
|
2018-04-09 17:30:36 +00:00
|
|
|
if (first)
|
2017-09-17 21:26:06 +00:00
|
|
|
goto clean;
|
|
|
|
}
|
|
|
|
|
2018-04-09 17:30:36 +00:00
|
|
|
if (!is_data)
|
2017-09-17 21:26:06 +00:00
|
|
|
continue;
|
|
|
|
|
2018-04-09 17:30:36 +00:00
|
|
|
if (cand_index == -1)
|
|
|
|
{
|
2017-09-17 21:26:06 +00:00
|
|
|
cand_index = last_index;
|
|
|
|
cand_track = track;
|
|
|
|
}
|
2015-09-16 20:39:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-09 17:30:36 +00:00
|
|
|
if (file_size != -1)
|
2017-09-18 00:52:11 +00:00
|
|
|
last_index = file_size;
|
|
|
|
|
2020-06-10 14:24:52 +00:00
|
|
|
if (update_cand(&cand_index, &last_index,
|
|
|
|
&largest, last_file, offset,
|
|
|
|
size, track_path, max_len))
|
2017-09-17 21:26:06 +00:00
|
|
|
rv = 0;
|
2015-09-16 20:39:47 +00:00
|
|
|
|
|
|
|
clean:
|
2017-09-18 00:46:02 +00:00
|
|
|
free(cue_dir);
|
2017-09-12 03:04:27 +00:00
|
|
|
free(tmp_token);
|
2017-09-17 21:26:06 +00:00
|
|
|
free(last_file);
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_close(fd);
|
2017-09-21 22:03:40 +00:00
|
|
|
free(fd);
|
2015-09-16 20:39:47 +00:00
|
|
|
return rv;
|
2017-09-12 03:04:27 +00:00
|
|
|
|
|
|
|
error:
|
2017-09-18 00:46:02 +00:00
|
|
|
free(cue_dir);
|
2017-09-12 03:04:27 +00:00
|
|
|
free(tmp_token);
|
2017-09-17 21:26:06 +00:00
|
|
|
free(last_file);
|
2017-09-12 03:04:27 +00:00
|
|
|
if (fd)
|
2017-09-21 21:38:29 +00:00
|
|
|
{
|
2017-09-17 05:31:58 +00:00
|
|
|
intfstream_close(fd);
|
2017-09-21 21:38:29 +00:00
|
|
|
free(fd);
|
|
|
|
}
|
2017-09-12 03:04:27 +00:00
|
|
|
return -errno;
|
2015-09-16 20:39:47 +00:00
|
|
|
}
|
2017-09-18 00:39:41 +00:00
|
|
|
|
2018-04-12 22:47:42 +00:00
|
|
|
bool cue_next_file(intfstream_t *fd,
|
|
|
|
const char *cue_path, char *path, uint64_t max_len)
|
2017-09-18 02:18:50 +00:00
|
|
|
{
|
2017-09-19 19:29:28 +00:00
|
|
|
bool rv = false;
|
|
|
|
char *tmp_token = (char*)malloc(MAX_TOKEN_LEN);
|
|
|
|
char *cue_dir = (char*)malloc(PATH_MAX_LENGTH);
|
|
|
|
cue_dir[0] = '\0';
|
2017-09-18 02:18:50 +00:00
|
|
|
|
|
|
|
fill_pathname_basedir(cue_dir, cue_path, PATH_MAX_LENGTH);
|
|
|
|
|
|
|
|
tmp_token[0] = '\0';
|
|
|
|
|
|
|
|
while (get_token(fd, tmp_token, MAX_TOKEN_LEN) > 0)
|
|
|
|
{
|
2019-08-01 23:16:18 +00:00
|
|
|
if (string_is_equal_noncase(tmp_token, "FILE"))
|
2017-09-18 02:18:50 +00:00
|
|
|
{
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
2018-04-12 22:47:42 +00:00
|
|
|
fill_pathname_join(path, cue_dir, tmp_token, (size_t)max_len);
|
2017-09-18 02:18:50 +00:00
|
|
|
rv = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(cue_dir);
|
|
|
|
free(tmp_token);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2017-09-20 07:55:53 +00:00
|
|
|
int gdi_find_track(const char *gdi_path, bool first,
|
2018-04-12 22:18:11 +00:00
|
|
|
char *track_path, uint64_t max_len)
|
2017-09-18 00:39:41 +00:00
|
|
|
{
|
|
|
|
int rv;
|
|
|
|
intfstream_info_t info;
|
2017-09-19 19:29:28 +00:00
|
|
|
char *tmp_token = (char*)malloc(MAX_TOKEN_LEN);
|
|
|
|
intfstream_t *fd = NULL;
|
2018-04-12 22:18:11 +00:00
|
|
|
uint64_t largest = 0;
|
2017-09-19 19:29:28 +00:00
|
|
|
int size = -1;
|
|
|
|
int mode = -1;
|
2018-04-12 22:18:11 +00:00
|
|
|
int64_t file_size = -1;
|
2017-09-18 00:39:41 +00:00
|
|
|
|
2017-09-19 19:29:28 +00:00
|
|
|
info.type = INTFSTREAM_FILE;
|
|
|
|
|
|
|
|
fd = (intfstream_t*)intfstream_init(&info);
|
2017-09-18 00:39:41 +00:00
|
|
|
|
|
|
|
if (!fd)
|
|
|
|
goto error;
|
|
|
|
|
2017-12-11 11:15:00 +00:00
|
|
|
if (!intfstream_open(fd, gdi_path,
|
2017-12-11 11:53:47 +00:00
|
|
|
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE))
|
2017-09-18 00:39:41 +00:00
|
|
|
{
|
|
|
|
RARCH_LOG("Could not open GDI file '%s': %s\n", gdi_path,
|
|
|
|
strerror(errno));
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
RARCH_LOG("Parsing GDI file '%s'...\n", gdi_path);
|
|
|
|
|
|
|
|
tmp_token[0] = '\0';
|
|
|
|
|
|
|
|
rv = -EINVAL;
|
|
|
|
|
|
|
|
/* Skip track count */
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
|
|
|
|
|
|
|
/* Track number */
|
|
|
|
while (get_token(fd, tmp_token, MAX_TOKEN_LEN) > 0)
|
|
|
|
{
|
|
|
|
/* Offset */
|
|
|
|
if (get_token(fd, tmp_token, MAX_TOKEN_LEN) <= 0)
|
|
|
|
{
|
|
|
|
errno = EINVAL;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mode */
|
|
|
|
if (get_token(fd, tmp_token, MAX_TOKEN_LEN) <= 0)
|
|
|
|
{
|
|
|
|
errno = EINVAL;
|
|
|
|
goto error;
|
|
|
|
}
|
2020-06-10 14:24:52 +00:00
|
|
|
|
2017-09-18 00:39:41 +00:00
|
|
|
mode = atoi(tmp_token);
|
|
|
|
|
|
|
|
/* Sector size */
|
|
|
|
if (get_token(fd, tmp_token, MAX_TOKEN_LEN) <= 0)
|
|
|
|
{
|
|
|
|
errno = EINVAL;
|
|
|
|
goto error;
|
|
|
|
}
|
2020-06-10 14:24:52 +00:00
|
|
|
|
2017-09-18 00:39:41 +00:00
|
|
|
size = atoi(tmp_token);
|
|
|
|
|
|
|
|
/* File name */
|
|
|
|
if (get_token(fd, tmp_token, MAX_TOKEN_LEN) <= 0)
|
|
|
|
{
|
|
|
|
errno = EINVAL;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for data track */
|
|
|
|
if (!(mode == 0 && size == 2352))
|
|
|
|
{
|
2017-09-20 07:55:53 +00:00
|
|
|
char *last_file = (char*)malloc(PATH_MAX_LENGTH + 1);
|
|
|
|
char *gdi_dir = (char*)malloc(PATH_MAX_LENGTH);
|
|
|
|
|
|
|
|
gdi_dir[0] = '\0';
|
|
|
|
|
|
|
|
fill_pathname_basedir(gdi_dir, gdi_path, PATH_MAX_LENGTH);
|
|
|
|
|
|
|
|
fill_pathname_join(last_file,
|
|
|
|
gdi_dir, tmp_token, PATH_MAX_LENGTH);
|
2017-12-11 12:21:44 +00:00
|
|
|
file_size = intfstream_get_file_size(last_file);
|
2017-09-18 00:39:41 +00:00
|
|
|
if (file_size < 0)
|
2017-09-20 07:55:53 +00:00
|
|
|
{
|
|
|
|
free(gdi_dir);
|
|
|
|
free(last_file);
|
2017-09-18 00:39:41 +00:00
|
|
|
goto error;
|
2017-09-20 07:55:53 +00:00
|
|
|
}
|
2017-09-19 19:29:28 +00:00
|
|
|
|
2018-04-12 22:18:11 +00:00
|
|
|
if ((uint64_t)file_size > largest)
|
2017-09-18 00:39:41 +00:00
|
|
|
{
|
2018-04-12 22:47:42 +00:00
|
|
|
strlcpy(track_path, last_file, (size_t)max_len);
|
|
|
|
|
|
|
|
rv = 0;
|
2017-09-18 00:39:41 +00:00
|
|
|
largest = file_size;
|
2018-04-12 22:47:42 +00:00
|
|
|
|
2017-09-18 00:39:41 +00:00
|
|
|
if (first)
|
2017-09-20 07:55:53 +00:00
|
|
|
{
|
|
|
|
free(gdi_dir);
|
|
|
|
free(last_file);
|
2017-09-18 00:39:41 +00:00
|
|
|
goto clean;
|
2017-09-20 07:55:53 +00:00
|
|
|
}
|
2017-09-18 00:39:41 +00:00
|
|
|
}
|
2017-09-20 07:55:53 +00:00
|
|
|
free(gdi_dir);
|
|
|
|
free(last_file);
|
2017-09-18 00:39:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Disc offset (not used?) */
|
|
|
|
if (get_token(fd, tmp_token, MAX_TOKEN_LEN) <= 0)
|
|
|
|
{
|
|
|
|
errno = EINVAL;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clean:
|
|
|
|
free(tmp_token);
|
|
|
|
intfstream_close(fd);
|
2017-09-20 10:18:31 +00:00
|
|
|
free(fd);
|
2017-09-18 00:39:41 +00:00
|
|
|
return rv;
|
|
|
|
|
|
|
|
error:
|
|
|
|
free(tmp_token);
|
|
|
|
if (fd)
|
2017-09-20 10:18:31 +00:00
|
|
|
{
|
2017-09-18 00:39:41 +00:00
|
|
|
intfstream_close(fd);
|
2017-09-20 10:18:31 +00:00
|
|
|
free(fd);
|
|
|
|
}
|
2017-09-18 00:39:41 +00:00
|
|
|
return -errno;
|
|
|
|
}
|
2017-09-18 02:18:50 +00:00
|
|
|
|
2017-09-20 07:55:53 +00:00
|
|
|
bool gdi_next_file(intfstream_t *fd, const char *gdi_path,
|
2018-04-12 22:18:11 +00:00
|
|
|
char *path, uint64_t max_len)
|
2017-09-18 02:18:50 +00:00
|
|
|
{
|
2017-09-19 19:29:28 +00:00
|
|
|
bool rv = false;
|
|
|
|
char *tmp_token = (char*)malloc(MAX_TOKEN_LEN);
|
2018-04-12 22:18:11 +00:00
|
|
|
int64_t offset = -1;
|
2017-09-18 02:18:50 +00:00
|
|
|
|
2017-09-19 19:29:28 +00:00
|
|
|
tmp_token[0] = '\0';
|
2017-09-18 02:18:50 +00:00
|
|
|
|
|
|
|
/* Skip initial track count */
|
|
|
|
offset = intfstream_tell(fd);
|
|
|
|
if (offset == 0)
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
|
|
|
|
|
|
|
/* Track number */
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
|
|
|
/* Offset */
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
|
|
|
/* Mode */
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
|
|
|
/* Sector size */
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
2017-09-20 07:55:53 +00:00
|
|
|
|
2017-09-18 02:18:50 +00:00
|
|
|
/* File name */
|
|
|
|
if (get_token(fd, tmp_token, MAX_TOKEN_LEN) > 0)
|
|
|
|
{
|
2017-09-20 07:55:53 +00:00
|
|
|
char *gdi_dir = (char*)malloc(PATH_MAX_LENGTH);
|
|
|
|
|
|
|
|
gdi_dir[0] = '\0';
|
|
|
|
|
|
|
|
fill_pathname_basedir(gdi_dir, gdi_path, PATH_MAX_LENGTH);
|
|
|
|
|
2018-04-12 22:47:42 +00:00
|
|
|
fill_pathname_join(path, gdi_dir, tmp_token, (size_t)max_len);
|
2020-06-10 14:24:52 +00:00
|
|
|
|
|
|
|
rv = true;
|
2017-09-20 07:55:53 +00:00
|
|
|
|
2017-09-18 02:18:50 +00:00
|
|
|
/* Disc offset */
|
|
|
|
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
2017-09-20 07:55:53 +00:00
|
|
|
|
|
|
|
free(gdi_dir);
|
2017-09-18 02:18:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
free(tmp_token);
|
|
|
|
return rv;
|
|
|
|
}
|