mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
(task_database) Simplify code - put logging behind DEBUG ifdef
This commit is contained in:
parent
8bad1559f9
commit
60161982b2
@ -155,52 +155,38 @@ static int intfstream_get_serial(intfstream_t *fd, char *serial, const char *fil
|
|||||||
{
|
{
|
||||||
if (string_is_equal(system_name, "Sony - PlayStation Portable"))
|
if (string_is_equal(system_name, "Sony - PlayStation Portable"))
|
||||||
{
|
{
|
||||||
if (detect_psp_game(fd, serial, filename) == 0)
|
if (detect_psp_game(fd, serial, filename) != 0)
|
||||||
return 0;
|
return 1;
|
||||||
RARCH_LOG("[Scanner]: Serial: %s\n", serial);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal(system_name, "Sony - PlayStation"))
|
else if (string_is_equal(system_name, "Sony - PlayStation"))
|
||||||
{
|
{
|
||||||
if (detect_ps1_game(fd, serial, filename) == 0)
|
if (detect_ps1_game(fd, serial, filename) != 0)
|
||||||
return 0;
|
return 1;
|
||||||
RARCH_LOG("[Scanner]: Serial: %s\n", serial);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal(system_name, "Nintendo - GameCube"))
|
else if (string_is_equal(system_name, "Nintendo - GameCube"))
|
||||||
{
|
{
|
||||||
if (detect_gc_game(fd, serial, filename) == 0)
|
if (detect_gc_game(fd, serial, filename) != 0)
|
||||||
return 0;
|
return 1;
|
||||||
RARCH_LOG("[Scanner]: Serial: %s\n", serial);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal(system_name, "Sega - Mega-CD - Sega CD"))
|
else if (string_is_equal(system_name, "Sega - Mega-CD - Sega CD"))
|
||||||
{
|
{
|
||||||
if (detect_scd_game(fd, serial, filename) == 0)
|
if (detect_scd_game(fd, serial, filename) != 0)
|
||||||
return 0;
|
return 1;
|
||||||
RARCH_LOG("[Scanner]: Serial: %s\n", serial);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal(system_name, "Sega - Saturn"))
|
else if (string_is_equal(system_name, "Sega - Saturn"))
|
||||||
{
|
{
|
||||||
if (detect_sat_game(fd, serial, filename) == 0)
|
if (detect_sat_game(fd, serial, filename) != 0)
|
||||||
return 0;
|
return 1;
|
||||||
RARCH_LOG("[Scanner]: Serial: %s\n", serial);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal(system_name, "Sega - Dreamcast"))
|
else if (string_is_equal(system_name, "Sega - Dreamcast"))
|
||||||
{
|
{
|
||||||
if (detect_dc_game(fd, serial, filename) == 0)
|
if (detect_dc_game(fd, serial, filename) != 0)
|
||||||
return 0;
|
return 1;
|
||||||
RARCH_LOG("[Scanner]: Serial: %s\n", serial);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else if (string_is_equal(system_name, "Nintendo - Wii"))
|
else if (string_is_equal(system_name, "Nintendo - Wii"))
|
||||||
{
|
{
|
||||||
if (detect_wii_game(fd, serial, filename) == 0)
|
if (detect_wii_game(fd, serial, filename) != 0)
|
||||||
return 0;
|
return 1;
|
||||||
RARCH_LOG("[Scanner]: Serial: %s\n", serial);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -279,13 +265,17 @@ static int task_database_cue_get_serial(const char *name, char* serial)
|
|||||||
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("%s: %s\n",
|
RARCH_LOG("%s: %s\n",
|
||||||
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
||||||
strerror(-rv));
|
strerror(-rv));
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
||||||
|
#endif
|
||||||
|
|
||||||
return intfstream_file_get_serial(track_path, offset, size, serial);
|
return intfstream_file_get_serial(track_path, offset, size, serial);
|
||||||
}
|
}
|
||||||
@ -301,13 +291,17 @@ static int task_database_gdi_get_serial(const char *name, char* serial)
|
|||||||
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("%s: %s\n",
|
RARCH_LOG("%s: %s\n",
|
||||||
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
||||||
strerror(-rv));
|
strerror(-rv));
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
||||||
|
#endif
|
||||||
|
|
||||||
return intfstream_file_get_serial(track_path, 0, SIZE_MAX, serial);
|
return intfstream_file_get_serial(track_path, 0, SIZE_MAX, serial);
|
||||||
}
|
}
|
||||||
@ -397,55 +391,61 @@ static int task_database_cue_get_crc(const char *name, uint32_t *crc)
|
|||||||
|
|
||||||
track_path[0] = '\0';
|
track_path[0] = '\0';
|
||||||
|
|
||||||
rv = cue_find_track(name, false, &offset, &size,
|
rv = cue_find_track(name, false, &offset, &size,
|
||||||
track_path, sizeof(track_path));
|
track_path, sizeof(track_path));
|
||||||
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("%s: %s\n",
|
RARCH_LOG("%s: %s\n",
|
||||||
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
||||||
strerror(-rv));
|
strerror(-rv));
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("CUE '%s' primary track: %s\n (%lu, %lu)\n",name, track_path, (unsigned long) offset, (unsigned long) size);
|
RARCH_LOG("CUE '%s' primary track: %s\n (%lu, %lu)\n",name, track_path, (unsigned long) offset, (unsigned long) size);
|
||||||
|
|
||||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
||||||
|
|
||||||
rv = intfstream_file_get_crc(track_path, offset, (size_t)size, crc);
|
rv = intfstream_file_get_crc(track_path, offset, (size_t)size, crc);
|
||||||
if (rv == 1)
|
if (rv == 1)
|
||||||
{
|
|
||||||
RARCH_LOG("CUE '%s' crc: %x\n", name, *crc);
|
RARCH_LOG("CUE '%s' crc: %x\n", name, *crc);
|
||||||
}
|
|
||||||
return rv;
|
return rv;
|
||||||
|
#else
|
||||||
|
return intfstream_file_get_crc(track_path, offset, (size_t)size, crc);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int task_database_gdi_get_crc(const char *name, uint32_t *crc)
|
static int task_database_gdi_get_crc(const char *name, uint32_t *crc)
|
||||||
{
|
{
|
||||||
char track_path[PATH_MAX_LENGTH];
|
char track_path[PATH_MAX_LENGTH];
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
track_path[0] = '\0';
|
track_path[0] = '\0';
|
||||||
|
|
||||||
rv = gdi_find_track(name, true, track_path, sizeof(track_path));
|
rv = gdi_find_track(name, true, track_path, sizeof(track_path));
|
||||||
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("%s: %s\n", msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
RARCH_LOG("%s: %s\n", msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK),
|
||||||
strerror(-rv));
|
strerror(-rv));
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("GDI '%s' primary track: %s\n", name, track_path);
|
RARCH_LOG("GDI '%s' primary track: %s\n", name, track_path);
|
||||||
|
|
||||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK));
|
||||||
|
|
||||||
rv = intfstream_file_get_crc(track_path, 0, SIZE_MAX, crc);
|
rv = intfstream_file_get_crc(track_path, 0, SIZE_MAX, crc);
|
||||||
if (rv == 1)
|
if (rv == 1)
|
||||||
{
|
|
||||||
RARCH_LOG("GDI '%s' crc: %x\n", name, *crc);
|
RARCH_LOG("GDI '%s' crc: %x\n", name, *crc);
|
||||||
}
|
|
||||||
return rv;
|
return rv;
|
||||||
|
#else
|
||||||
|
return intfstream_file_get_crc(track_path, 0, SIZE_MAX, crc);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool task_database_chd_get_crc(const char *name, uint32_t *crc)
|
static bool task_database_chd_get_crc(const char *name, uint32_t *crc)
|
||||||
@ -460,10 +460,10 @@ static bool task_database_chd_get_crc(const char *name, uint32_t *crc)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rv = intfstream_get_crc(fd, crc);
|
rv = intfstream_get_crc(fd, crc);
|
||||||
|
#ifdef DEBUG
|
||||||
if (rv)
|
if (rv)
|
||||||
{
|
|
||||||
RARCH_LOG("CHD '%s' crc: %x\n", name, *crc);
|
RARCH_LOG("CHD '%s' crc: %x\n", name, *crc);
|
||||||
}
|
#endif
|
||||||
if (fd)
|
if (fd)
|
||||||
{
|
{
|
||||||
intfstream_close(fd);
|
intfstream_close(fd);
|
||||||
@ -492,7 +492,9 @@ static void task_database_cue_prune(database_info_handle_t *db,
|
|||||||
if (db->list->elems[i].data
|
if (db->list->elems[i].data
|
||||||
&& string_is_equal(path, db->list->elems[i].data))
|
&& string_is_equal(path, db->list->elems[i].data))
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("Pruning file referenced by cue: %s\n", path);
|
RARCH_LOG("Pruning file referenced by cue: %s\n", path);
|
||||||
|
#endif
|
||||||
free(db->list->elems[i].data);
|
free(db->list->elems[i].data);
|
||||||
db->list->elems[i].data = NULL;
|
db->list->elems[i].data = NULL;
|
||||||
}
|
}
|
||||||
|
@ -364,7 +364,9 @@ int detect_gc_game(intfstream_t *fd, char *game_id, const char *filename)
|
|||||||
/** Scrub files with bad data and log **/
|
/** Scrub files with bad data and log **/
|
||||||
if (raw_game_id[0] == '\0' || raw_game_id[0] == ' ')
|
if (raw_game_id[0] == '\0' || raw_game_id[0] == ' ')
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("[Scanner]: Scrubbing: %s\n", filename);
|
RARCH_LOG("[Scanner]: Scrubbing: %s\n", filename);
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,7 +593,9 @@ int detect_sat_game(intfstream_t *fd, char *game_id, const char *filename)
|
|||||||
/** Scrub files with bad data and log **/
|
/** Scrub files with bad data and log **/
|
||||||
if (raw_game_id[0] == '\0' || raw_game_id[0] == ' ')
|
if (raw_game_id[0] == '\0' || raw_game_id[0] == ' ')
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("[Scanner]: Scrubbing: %s\n", filename);
|
RARCH_LOG("[Scanner]: Scrubbing: %s\n", filename);
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -881,7 +885,9 @@ int detect_wii_game(intfstream_t *fd, char *game_id, const char *filename)
|
|||||||
/** Scrub files with bad data and log **/
|
/** Scrub files with bad data and log **/
|
||||||
if (raw_game_id[0] == '\0' || raw_game_id[0] == ' ')
|
if (raw_game_id[0] == '\0' || raw_game_id[0] == ' ')
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("[Scanner]: Scrubbing: %s\n", filename);
|
RARCH_LOG("[Scanner]: Scrubbing: %s\n", filename);
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -944,7 +950,9 @@ int detect_system(intfstream_t *fd, const char **system_name, const char * filen
|
|||||||
int i;
|
int i;
|
||||||
char magic[50];
|
char magic[50];
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("[Scanner]: %s\n", msg_hash_to_str(MSG_COMPARING_WITH_KNOWN_MAGIC_NUMBERS));
|
RARCH_LOG("[Scanner]: %s\n", msg_hash_to_str(MSG_COMPARING_WITH_KNOWN_MAGIC_NUMBERS));
|
||||||
|
#endif
|
||||||
for (i = 0; MAGIC_NUMBERS[i].system_name != NULL; i++)
|
for (i = 0; MAGIC_NUMBERS[i].system_name != NULL; i++)
|
||||||
{
|
{
|
||||||
if (intfstream_seek(fd, MAGIC_NUMBERS[i].offset, SEEK_SET) >= 0)
|
if (intfstream_seek(fd, MAGIC_NUMBERS[i].offset, SEEK_SET) >= 0)
|
||||||
@ -955,16 +963,20 @@ int detect_system(intfstream_t *fd, const char **system_name, const char * filen
|
|||||||
if (memcmp(MAGIC_NUMBERS[i].magic, magic, MAGIC_NUMBERS[i].length_magic) == 0)
|
if (memcmp(MAGIC_NUMBERS[i].magic, magic, MAGIC_NUMBERS[i].length_magic) == 0)
|
||||||
{
|
{
|
||||||
*system_name = MAGIC_NUMBERS[i].system_name;
|
*system_name = MAGIC_NUMBERS[i].system_name;
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("[Scanner]: Name: %s\n", filename);
|
RARCH_LOG("[Scanner]: Name: %s\n", filename);
|
||||||
RARCH_LOG("[Scanner]: System: %s\n", MAGIC_NUMBERS[i].system_name);
|
RARCH_LOG("[Scanner]: System: %s\n", MAGIC_NUMBERS[i].system_name);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("[Scanner]: Name: %s\n", filename);
|
RARCH_LOG("[Scanner]: Name: %s\n", filename);
|
||||||
RARCH_LOG("[Scanner]: System: Unknown\n");
|
RARCH_LOG("[Scanner]: System: Unknown\n");
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1030,12 +1042,16 @@ int cue_find_track(const char *cue_path, bool first,
|
|||||||
if (!intfstream_open(fd, cue_path,
|
if (!intfstream_open(fd, cue_path,
|
||||||
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE))
|
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE))
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("Could not open CUE file '%s': %s\n", cue_path,
|
RARCH_LOG("Could not open CUE file '%s': %s\n", cue_path,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("Parsing CUE file '%s'...\n", cue_path);
|
RARCH_LOG("Parsing CUE file '%s'...\n", cue_path);
|
||||||
|
#endif
|
||||||
|
|
||||||
tmp_token[0] = '\0';
|
tmp_token[0] = '\0';
|
||||||
|
|
||||||
@ -1083,7 +1099,9 @@ int cue_find_track(const char *cue_path, bool first,
|
|||||||
|
|
||||||
if (sscanf(tmp_token, "%02d:%02d:%02d", &m, &s, &f) < 3)
|
if (sscanf(tmp_token, "%02d:%02d:%02d", &m, &s, &f) < 3)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("Error parsing time stamp '%s'\n", tmp_token);
|
RARCH_LOG("Error parsing time stamp '%s'\n", tmp_token);
|
||||||
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1181,12 +1199,16 @@ int gdi_find_track(const char *gdi_path, bool first,
|
|||||||
if (!intfstream_open(fd, gdi_path,
|
if (!intfstream_open(fd, gdi_path,
|
||||||
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE))
|
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE))
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("Could not open GDI file '%s': %s\n", gdi_path,
|
RARCH_LOG("Could not open GDI file '%s': %s\n", gdi_path,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
RARCH_LOG("Parsing GDI file '%s'...\n", gdi_path);
|
RARCH_LOG("Parsing GDI file '%s'...\n", gdi_path);
|
||||||
|
#endif
|
||||||
|
|
||||||
tmp_token[0] = '\0';
|
tmp_token[0] = '\0';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user