MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / scan_directory

Function scan_directory

gtk/src/callbacks.c:1707–1753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1705}
1706
1707static void
1708scan_directory (GFile *dir, GListStore *file_list, gboolean recursive)
1709{
1710 g_autoptr(GFileEnumerator) dir_enum = NULL;
1711 g_autoptr(GError) error = NULL;
1712
1713 ghb_log("Searching directory %s", g_file_peek_path(dir));
1714
1715 // Get info about the files in the directory
1716 dir_enum = g_file_enumerate_children(dir, "standard::name,standard::is-symlink,standard::type",
1717 G_FILE_QUERY_INFO_NONE, NULL, &error);
1718
1719 if (dir_enum)
1720 {
1721 GFileInfo *info;
1722 GFile *file;
1723 hb_list_t *extensions = ghb_get_excluded_extensions_list();
1724
1725 while (g_file_enumerator_iterate(dir_enum, &info, &file, NULL, &error))
1726 {
1727 if (!info) break;
1728
1729 // Avoid symlinks to directories in order to avoid infinite loops
1730 if (recursive && !g_file_info_get_is_symlink(info)
1731 && g_file_info_get_file_type(info) == G_FILE_TYPE_DIRECTORY)
1732 {
1733 scan_directory(file, file_list, TRUE);
1734 }
1735 else if (g_file_info_get_file_type(info) == G_FILE_TYPE_REGULAR
1736 && file_has_allowed_extension(file, extensions))
1737 {
1738 g_debug("Found file: %s", g_file_peek_path(file));
1739 g_list_store_insert_sorted(file_list, g_object_ref(file),
1740 (GCompareDataFunc) file_name_compare, NULL);
1741 }
1742 }
1743 if (error)
1744 {
1745 g_warning("Could not scan files: %s", error->message);
1746 }
1747 ghb_free_list(extensions);
1748 }
1749 else
1750 {
1751 g_warning("Could not enumerate directory: %s", error->message);
1752 }
1753}
1754
1755static void
1756source_dialog_start_scan (GtkFileChooser *chooser, int title_id)

Callers 1

source_dialog_start_scanFunction · 0.85

Calls 4

ghb_logFunction · 0.85
ghb_free_listFunction · 0.85

Tested by

no test coverage detected