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

Function set_destination_settings

gtk/src/callbacks.c:856–1080  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

854}
855
856static void
857set_destination_settings(signal_user_data_t *ud, GhbValue *settings)
858{
859 const gchar *extension, *dest_file, *dest_dir;
860 gchar *filename;
861
862 extension = get_extension(ud, settings);
863
864 ghb_log_func();
865 dest_file = ghb_dict_get_string(ud->settings, "dest_file");
866 if (dest_file == NULL)
867 {
868 // Initialize destination filename if it has no value yet.
869 // If auto-naming is disabled, this will be the default filename.
870 GString *str = g_string_new("");
871 const gchar *vol_name;
872 vol_name = ghb_dict_get_string(settings, "volume");
873 g_string_append_printf(str, "%s", vol_name);
874 g_string_append_printf(str, ".%s", extension);
875 filename = g_string_free(str, FALSE);
876 ghb_dict_set_string(settings, "dest_file", filename);
877 g_free(filename);
878 }
879 ghb_dict_set(settings, "dest_dir", ghb_value_dup(
880 ghb_dict_get_value(ud->prefs, "destination_dir")));
881 if (ghb_dict_get_bool(ud->prefs, "auto_name"))
882 {
883 GString *str = g_string_new("");
884 const gchar *p;
885
886 p = ghb_dict_get_string(ud->prefs, "auto_name_template");
887 // {source-path} is only allowed as the first element of the
888 // template since the path must come first in the filename
889 if (p != NULL &&
890 (!strncasecmp(p, "{source-path}", strlen("{source-path}")) ||
891 !strncasecmp(p, "{source_path}", strlen("{source_path}"))))
892 {
893 const char *source = ghb_get_scan_source();
894 if (source != NULL)
895 {
896 char * dirname = g_path_get_dirname(source);
897 // if dirname is a directory and it is writable...
898 if (dirname != NULL &&
899 g_file_test(dirname, G_FILE_TEST_IS_DIR) &&
900 access(dirname, W_OK) == 0)
901 {
902 ghb_dict_set_string(settings, "dest_dir", dirname);
903 }
904 g_free(dirname);
905 }
906 p += strlen("{source-path}");
907 }
908 while (*p)
909 {
910 if (!strncasecmp(p, "{source}", strlen("{source}")))
911 {
912 const gchar *vol_name;
913 vol_name = ghb_dict_get_string(settings, "volume");

Callers 2

ghb_set_destinationFunction · 0.85
ghb_set_title_settingsFunction · 0.85

Calls 15

get_extensionFunction · 0.85
ghb_dict_get_stringFunction · 0.85
ghb_dict_set_stringFunction · 0.85
ghb_dict_get_valueFunction · 0.85
ghb_dict_get_boolFunction · 0.85
ghb_get_scan_sourceFunction · 0.85
ghb_dict_get_intFunction · 0.85
ghb_settings_combo_intFunction · 0.85
get_creation_dateFunction · 0.85

Tested by

no test coverage detected