Improved searching for VobSubs inside RAR archives even if the names do not match the movie name. Do not display VobSubs whose timecodes are < 0 which would make all VobSubs appear from the start on upon seeking. Patches by "Reder, Uwe" <Uwe.Reder@3SOFT.de>.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11310 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
mosu 2003-10-28 22:36:56 +00:00
parent 09c8f3f996
commit 7931d804f1
1 changed files with 30 additions and 3 deletions

View File

@ -88,11 +88,38 @@ rar_open(const char *const filename, const char *const mode)
p++;
}
rc = urarlib_get(&stream->data, &stream->size, (char*) p, rar_filename, "");
free(rar_filename);
if (!rc) {
free(stream);
return NULL;
/* There is no matching filename in the archive. However, sometimes
* the files we are looking for have been given arbitrary names in the archive.
* Let's look for a file with an exact match in the extension only. */
int i, num_files, name_len;
ArchiveList_struct *list, *lp;
/* the cast in the next line is a hack to overcome a design flaw (IMHO) in unrarlib */
num_files = urarlib_list (rar_filename, (ArchiveList_struct *)&list);
if (num_files > 0) {
char *demanded_ext;
demanded_ext = strrchr (p, '.');
if (demanded_ext) {
int demanded_ext_len = strlen (demanded_ext);
for (i=0, lp=list; i<num_files; i++, lp=lp->next) {
name_len = strlen (lp->item.Name);
if (name_len >= demanded_ext_len && !strcasecmp (lp->item.Name + name_len - demanded_ext_len, demanded_ext)) {
if ((rc = urarlib_get(&stream->data, &stream->size, lp->item.Name, rar_filename, ""))) {
break;
}
}
}
}
urarlib_freelist (list);
}
if (!rc) {
free(rar_filename);
free(stream);
return NULL;
}
}
free(rar_filename);
stream->pos = 0;
}
return stream;