| 4842 | } |
| 4843 | |
| 4844 | int hb_preset_insert(const hb_preset_index_t *path, const hb_value_t *dict) |
| 4845 | { |
| 4846 | hb_value_t *folder = NULL; |
| 4847 | |
| 4848 | if (dict == NULL || path == NULL || path->depth < 0) |
| 4849 | return -1; |
| 4850 | |
| 4851 | int index = path->index[path->depth - 1]; |
| 4852 | hb_preset_index_t folder_path = *path; |
| 4853 | folder_path.depth--; |
| 4854 | folder = hb_presets_get_folder_children(&folder_path); |
| 4855 | if (folder) |
| 4856 | { |
| 4857 | hb_value_t *dup = hb_value_dup(dict); |
| 4858 | presets_clean(dup, hb_preset_template); |
| 4859 | if (hb_value_array_len(folder) <= index) |
| 4860 | { |
| 4861 | index = hb_value_array_len(folder); |
| 4862 | hb_value_array_append(folder, dup); |
| 4863 | } |
| 4864 | else |
| 4865 | { |
| 4866 | hb_value_array_insert(folder, index, dup); |
| 4867 | } |
| 4868 | } |
| 4869 | else |
| 4870 | { |
| 4871 | hb_error("hb_preset_insert: not found"); |
| 4872 | return -1; |
| 4873 | } |
| 4874 | return index; |
| 4875 | } |
| 4876 | |
| 4877 | int hb_preset_append(const hb_preset_index_t *path, const hb_value_t *dict) |
| 4878 | { |
nothing calls this directly
no test coverage detected