Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
import_sequence.c
Go to the documentation of this file.
1/*
2 * This file is part of Ansel, Copyright (C) 2026 Paolo SANTUCCI.
3 * SPDX-License-Identifier: GPL-3.0-or-later
4 */
6#include "common/utility.h"
7#include "system/mem_alloc.h"
8
10{
11 const char *extension = dt_util_path_get_extension(filename);
12 const size_t length = IS_NULL_PTR(extension) ? strlen(filename) : (size_t)(extension - filename - 1);
13 char *capture = g_strndup(filename, length);
14 gpointer assigned = g_hash_table_lookup(sequences->captures, capture);
16 {
19 }
20 else
23}
24
26{
27 dt_control_import_t *data = request->data;
29 dt_free(data->target_dir);
30 data->target_dir = NULL;
31 char *destination = dt_build_filename_from_pattern(request->filename, destination_sequence, request->image, data);
32 if(IS_NULL_PTR(destination)) return NULL;
33
34 const int reserved = GPOINTER_TO_INT(g_hash_table_lookup(sequences->destinations, destination));
35 if(reserved == request->capture_sequence)
36 {
37 dt_free(destination);
38 dt_free(data->target_dir);
39 data->target_dir = NULL;
41 destination = dt_build_filename_from_pattern(request->filename, destination_sequence, request->image, data);
42 }
43
44 if(!IS_NULL_PTR(destination) && !g_hash_table_contains(sequences->destinations, destination))
46 return destination;
47}
const char * extension(dt_imageio_module_data_t *data)
Definition avif.c:651
gchar * dt_build_filename_from_pattern(const char *const filename, const int index, dt_image_t *img, dt_control_import_t *data)
Build a full path for a given image file, given a pattern.
Definition import_jobs.c:79
char * dt_import_sequence_destination(dt_import_sequence_t *sequences, const dt_import_destination_t *request)
Expand and reserve a destination, retrying a sibling collision exactly once.
int dt_import_sequence_assign(dt_import_sequence_t *sequences, const char *filename)
Assign a capture number, retaining it even when subsequent expansion fails.
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Definition macros.h:96
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
Definition mem_alloc.h:171
Borrowed inputs for one destination expansion.
dt_control_import_t * data
Job-local numbering and reservation state; table lifetime belongs to the worker.
const char * dt_util_path_get_extension(const char *path)
Locate a normal filename extension in a path basename.
Definition utility.c:1033