| @@ -28,6 +28,7 @@ · 27 unmodified lines |
| 28 | #include "misc/charset_conv.h" | 28 | #include "misc/charset_conv.h" |
| 29 | #include "misc/thread_tools.h" | 29 | #include "misc/thread_tools.h" |
| 30 | #include "options/path.h" | 30 | #include "options/path.h" |
| | 31 | #include "player/core.h" |
| 31 | #include "stream/stream.h" | 32 | #include "stream/stream.h" |
| 32 | #include "osdep/io.h" | 33 | #include "osdep/io.h" |
| 33 | #include "misc/natural_sort.h" | 34 | #include "misc/natural_sort.h" |
| @@ -410,28 +411,17 @@ static int cmp_dir_entry(const void *a, const void *b) · 376 unmodified lines |
| 410 | } | 411 | } |
| 411 | } | 412 | } |
| 412 | | 413 | |
| 413 | static bool has_str(bstr ext, char **list) | | |
| 414 | { | | |
| 415 | if (!list) | | |
| 416 | return false; | | |
| 417 | while (*list) { | | |
| 418 | if (!bstrcasecmp0(ext, *list++)) | | |
| 419 | return true; | | |
| 420 | } | | |
| 421 | return false; | | |
| 422 | } | | |
| 423 | | | |
| 424 | static bool test_path(struct pl_parser *p, char *path, int autocreate) | 414 | static bool test_path(struct pl_parser *p, char *path, int autocreate) |
| 425 | { | 415 | { |
| 426 | if (autocreate & AUTO_ANY) | 416 | if (autocreate & AUTO_ANY) |
| 427 | return true; | 417 | return true; |
| 428 | | 418 | |
| 429 | bstr ext = bstr_get_ext(bstr0(path)); | 419 | bstr ext = bstr_get_ext(bstr0(path)); |
| 430 | if (autocreate & AUTO_VIDEO && has_str(ext, p->mp_opts->video_exts)) | 420 | if (autocreate & AUTO_VIDEO && str_in_list(ext, p->mp_opts->video_exts)) |
| 431 | return true; | 421 | return true; |
| 432 | if (autocreate & AUTO_AUDIO && has_str(ext, p->mp_opts->audio_exts)) | 422 | if (autocreate & AUTO_AUDIO && str_in_list(ext, p->mp_opts->audio_exts)) |
| 433 | return true; | 423 | return true; |
| 434 | if (autocreate & AUTO_IMAGE && has_str(ext, p->mp_opts->image_exts)) | 424 | if (autocreate & AUTO_IMAGE && str_in_list(ext, p->mp_opts->image_exts)) |
| 435 | return true; | 425 | return true; |
| 436 | | 426 | |
| 437 | return false; | 427 | return false; |
| @@ -521,11 +511,11 @@ static int parse_dir(struct pl_parser *p) · 83 unmodified lines |
| 521 | autocreate = AUTO_VIDEO | AUTO_AUDIO | AUTO_IMAGE; | 511 | autocreate = AUTO_VIDEO | AUTO_AUDIO | AUTO_IMAGE; |
| 522 | break; | 512 | break; |
| 523 | case 3: // same | 513 | case 3: // same |
| 524 | if (has_str(ext, p->mp_opts->video_exts)) { | 514 | if (str_in_list(ext, p->mp_opts->video_exts)) { |
| 525 | autocreate = AUTO_VIDEO; | 515 | autocreate = AUTO_VIDEO; |
| 526 | } else if (has_str(ext, p->mp_opts->audio_exts)) { | 516 | } else if (str_in_list(ext, p->mp_opts->audio_exts)) { |
| 527 | autocreate = AUTO_AUDIO; | 517 | autocreate = AUTO_AUDIO; |
| 528 | } else if (has_str(ext, p->mp_opts->image_exts)) { | 518 | } else if (str_in_list(ext, p->mp_opts->image_exts)) { |
| 529 | autocreate = AUTO_IMAGE; | 519 | autocreate = AUTO_IMAGE; |
| 530 | } | 520 | } |
| 531 | break; | 521 | break; |
| @@ -543,11 +533,11 @@ static int parse_dir(struct pl_parser *p) · 11 unmodified lines |
| 543 | autocreate = AUTO_NONE; | 533 | autocreate = AUTO_NONE; |
| 544 | if (!p->opts->directory_filter || !p->opts->directory_filter[0]) | 534 | if (!p->opts->directory_filter || !p->opts->directory_filter[0]) |
| 545 | autocreate = AUTO_ANY; | 535 | autocreate = AUTO_ANY; |
| 546 | if (has_str(bstr0("video"), p->opts->directory_filter)) | 536 | if (str_in_list(bstr0("video"), p->opts->directory_filter)) |
| 547 | autocreate |= AUTO_VIDEO; | 537 | autocreate |= AUTO_VIDEO; |
| 548 | if (has_str(bstr0("audio"), p->opts->directory_filter)) | 538 | if (str_in_list(bstr0("audio"), p->opts->directory_filter)) |
| 549 | autocreate |= AUTO_AUDIO; | 539 | autocreate |= AUTO_AUDIO; |
| 550 | if (has_str(bstr0("image"), p->opts->directory_filter)) | 540 | if (str_in_list(bstr0("image"), p->opts->directory_filter)) |
| 551 | autocreate |= AUTO_IMAGE; | 541 | autocreate |= AUTO_IMAGE; |
| 552 | } | 542 | } |
| 553 | if (!stream->is_directory) | 543 | if (!stream->is_directory) |