static int cue_get_serial(database_state_handle_t *db_state, database_info_handle_t *db, const char *name, char* serial) { char *track_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); int ret = 0; int32_t offset = 0; int rv = 0; track_path[0] = '\0'; rv = find_first_data_track(name, &offset, track_path, PATH_MAX_LENGTH); if (rv < 0) { RARCH_LOG("%s: %s\n", msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK), strerror(-rv)); free(track_path); return 0; } RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK)); ret = iso_get_serial(db_state, db, track_path, serial); free(track_path); return ret; }
static int database_info_iterate_playlist( database_state_handle_t *db_state, database_info_handle_t *db, const char *name) { uint32_t extension_hash = 0; char parent_dir[PATH_MAX_LENGTH] = {0}; path_parent_dir(parent_dir); extension_hash = msg_hash_calculate(path_get_extension(name)); switch (extension_hash) { case HASH_EXTENSION_ZIP: #ifdef HAVE_ZLIB db->type = DATABASE_TYPE_ITERATE_ZIP; memset(&db->state, 0, sizeof(zlib_transfer_t)); db_state->zip_name[0] = '\0'; db->state.type = ZLIB_TRANSFER_INIT; return 1; #endif case HASH_EXTENSION_CUE: case HASH_EXTENSION_CUE_UPPERCASE: db_state->serial[0] = '\0'; cue_get_serial(db_state, db, name, db_state->serial); db->type = DATABASE_TYPE_SERIAL_LOOKUP; return 1; case HASH_EXTENSION_ISO: case HASH_EXTENSION_ISO_UPPERCASE: db_state->serial[0] = '\0'; iso_get_serial(db_state, db, name, db_state->serial); db->type = DATABASE_TYPE_SERIAL_LOOKUP; return 1; default: { ssize_t ret; int read_from = read_file(name, (void**)&db_state->buf, &ret); if (read_from != 1 || ret <= 0) return 0; #ifdef HAVE_ZLIB db_state->crc = zlib_crc32_calculate(db_state->buf, ret); #endif db->type = DATABASE_TYPE_CRC_LOOKUP; } break; } return 1; }
static int task_database_iterate_playlist( database_state_handle_t *db_state, database_info_handle_t *db, const char *name) { switch (msg_hash_to_file_type(msg_hash_calculate(path_get_extension(name)))) { case FILE_TYPE_COMPRESSED: #ifdef HAVE_COMPRESSION database_info_set_type(db, DATABASE_TYPE_CRC_LOOKUP); /* first check crc of archive itself */ return file_get_crc(db_state, name, &db_state->archive_crc); #else break; #endif case FILE_TYPE_CUE: db_state->serial[0] = '\0'; if (cue_get_serial(db_state, db, name, db_state->serial)) { database_info_set_type(db, DATABASE_TYPE_SERIAL_LOOKUP); } else { database_info_set_type(db, DATABASE_TYPE_CRC_LOOKUP); return file_get_crc(db_state, name, &db_state->crc); } break; case FILE_TYPE_ISO: db_state->serial[0] = '\0'; iso_get_serial(db_state, db, name, db_state->serial); database_info_set_type(db, DATABASE_TYPE_SERIAL_LOOKUP); break; case FILE_TYPE_CHD: db_state->serial[0] = '\0'; if (chd_get_serial(db_state, db, name, db_state->serial)) { database_info_set_type(db, DATABASE_TYPE_SERIAL_LOOKUP); } else { database_info_set_type(db, DATABASE_TYPE_CRC_LOOKUP); return chd_get_crc(db_state, name, &db_state->crc); } break; case FILE_TYPE_LUTRO: database_info_set_type(db, DATABASE_TYPE_ITERATE_LUTRO); break; default: database_info_set_type(db, DATABASE_TYPE_CRC_LOOKUP); return file_get_crc(db_state, name, &db_state->crc); } return 1; }
static int cue_get_serial(database_state_handle_t *db_state, database_info_handle_t *db, const char *name, char* serial) { char track_path[PATH_MAX_LENGTH]; int32_t offset = 0; int rv = find_first_data_track(name, &offset, track_path, PATH_MAX_LENGTH); if (rv < 0) { RARCH_LOG("Could not find valid data track: %s\n", strerror(-rv)); return rv; } RARCH_LOG("Reading 1st data track...\n"); return iso_get_serial(db_state, db, track_path, serial); }
static int task_database_iterate_playlist( database_state_handle_t *db_state, database_info_handle_t *db, const char *name) { uint32_t extension_hash = 0; char parent_dir[PATH_MAX_LENGTH] = {0}; path_parent_dir(parent_dir); extension_hash = msg_hash_calculate(path_get_extension(name)); switch (extension_hash) { case HASH_EXTENSION_ZIP: #ifdef HAVE_ZLIB db->type = DATABASE_TYPE_ITERATE_ZIP; memset(&db->state, 0, sizeof(file_archive_transfer_t)); db_state->zip_name[0] = '\0'; db->state.type = ZLIB_TRANSFER_INIT; return file_get_crc(db_state, name, &db_state->zip_crc); #endif case HASH_EXTENSION_CUE: case HASH_EXTENSION_CUE_UPPERCASE: db_state->serial[0] = '\0'; cue_get_serial(db_state, db, name, db_state->serial); db->type = DATABASE_TYPE_SERIAL_LOOKUP; return 1; case HASH_EXTENSION_ISO: case HASH_EXTENSION_ISO_UPPERCASE: db_state->serial[0] = '\0'; iso_get_serial(db_state, db, name, db_state->serial); db->type = DATABASE_TYPE_SERIAL_LOOKUP; return 1; default: { db->type = DATABASE_TYPE_CRC_LOOKUP; return file_get_crc(db_state, name, &db_state->crc); } break; } return 1; }
static int cue_get_serial(database_state_handle_t *db_state, database_info_handle_t *db, const char *name, char* serial) { int32_t offset = 0; char track_path[PATH_MAX_LENGTH] = {0}; int rv = find_first_data_track(name, &offset, track_path, PATH_MAX_LENGTH); if (rv < 0) { RARCH_LOG("%s: %s\n", msg_hash_to_str(MSG_COULD_NOT_FIND_VALID_DATA_TRACK), strerror(-rv)); return rv; } RARCH_LOG("%s\n", msg_hash_to_str(MSG_READING_FIRST_DATA_TRACK)); return iso_get_serial(db_state, db, track_path, serial); }
static int task_database_iterate_playlist( database_state_handle_t *db_state, database_info_handle_t *db, const char *name) { char parent_dir[PATH_MAX_LENGTH] = {0}; path_parent_dir(parent_dir); switch (msg_hash_to_file_type(msg_hash_calculate(path_get_extension(name)))) { case FILE_TYPE_COMPRESSED: #ifdef HAVE_ZLIB db->type = DATABASE_TYPE_ITERATE_ZIP; memset(&db->state, 0, sizeof(file_archive_transfer_t)); db_state->zip_name[0] = '\0'; db->state.type = ZLIB_TRANSFER_INIT; return file_get_crc(db_state, name, &db_state->zip_crc); #else break; #endif case FILE_TYPE_CUE: db_state->serial[0] = '\0'; cue_get_serial(db_state, db, name, db_state->serial); db->type = DATABASE_TYPE_SERIAL_LOOKUP; break; case FILE_TYPE_ISO: db_state->serial[0] = '\0'; iso_get_serial(db_state, db, name, db_state->serial); db->type = DATABASE_TYPE_SERIAL_LOOKUP; break; case FILE_TYPE_LUTRO: db->type = DATABASE_TYPE_ITERATE_LUTRO; break; default: db->type = DATABASE_TYPE_CRC_LOOKUP; return file_get_crc(db_state, name, &db_state->crc); } return 1; }