37#include <glib/gstdio.h>
58 dt_control_log(
_(
"Impossible to create directory %s.\nThe target may be full or read-only.\n"), path);
85 params->filename = filename;
247 (success) ?
"succeeded" :
"failed");
269 (success) ?
"succeeded" :
"failed");
274 return success ? 1 : 0;
306 for(
int seq = 1; seq < 10000; seq++)
407 const char *filename = (
const char*) img->data;
423 fprintf(
stderr,
"[Import] Could not import file from disk: empty file path\n");
457 dt_control_log(
_(
"The imported file differs from the original, which was not deleted: %s"), filename);
459 dt_control_log(
_(
"The imported file was verified but the original could not be deleted: %s"), filename);
467 const char *
style_name = (
const char *)s->data;
469 if(style_id <= 0)
continue;
482 const gboolean folder_survey)
484 gchar message[128] = { 0 };
488 ngettext(
"Capture: importing %i/%i image",
"Capture: importing %i/%i images", index),
492 ngettext(
"Importing %i/%i image",
"Importing %i/%i images", index),
541 const char *filename = (
const char *)img->data;
542 int capture_sequence = 0;
544 gchar *destination =
NULL;
613 if(index == 1 &&
xmps <= 1)
623 ?
ngettext(
"Capture: imported %d image.",
"Capture: imported %d images.", index)
624 :
ngettext(
"Imported %d image",
"Imported %d images", index), index);
625 fprintf(
stdout,
"%d files imported in database.\n\n", index);
static void error(char *msg)
void cleanup(dt_imageio_module_format_t *self)
void dt_collection_update_query(const dt_collection_t *collection, dt_collection_change_t query_change, dt_collection_properties_t changed_property, GList *list)
dt_collection_t * dt_collection_get_global(void)
void dt_collection_notify_imported(const int32_t imgid, const gchar *known_image_folder, gint64 *last_refresh_us)
void dt_collection_load_filmroll(dt_collection_t *collection, const int32_t imgid, dt_collection_import_view_t view_policy, gboolean set_mouse_over)
@ DT_COLLECTION_PROP_UNDEF
@ DT_COLLECTION_CHANGE_NEW_QUERY
dt_collection_import_view_t
@ DT_COLLECTION_IMPORT_VIEW_KEEP
@ DT_COLLECTION_IMPORT_VIEW_GRID
@ DT_COLLECTION_IMPORT_VIEW_IMAGE
const dt_colormatrix_t dt_aligned_pixel_t out
void dt_conf_set_int(const char *name, int val)
int32_t dt_image_import(const int32_t film_id, const char *filename, gboolean raise_signals)
char * dt_image_get_text_path_from_path(const char *image_path)
void dt_image_init(dt_image_t *img)
GList * dt_image_find_xmps(const char *filename)
int dt_image_read_duplicates(const uint32_t id, const char *filename, const gboolean clear_selection)
char * dt_image_build_text_path_from_path(const char *image_path)
void dt_image_history_changed(const int32_t imgid, const gboolean refresh_filmstrip)
void dt_control_log(const char *msg,...)
struct dt_control_t * dt_control_get_global(void)
void * dt_control_image_enumerator_alloc()
void dt_control_image_enumerator_cleanup(void *p)
void * dt_alloc_align(size_t size)
Allocate cacheline-aligned memory.
gboolean dt_datetime_unix_to_exif(char *exif, const size_t exif_size, const time_t *unix)
#define DT_DATETIME_EXIF_LENGTH
int dt_exif_read(dt_image_t *img, const char *path)
What a photograph says about itself: the EXIF, IPTC and XMP tags a camera and a cataloguer write,...
int dt_film_new(dt_film_t *film, const char *directory)
void dt_hm_batch_state_cleanup(dt_hm_batch_state_t *batch)
Release resources held by a batch state (the cached order). Safe to call on a zeroed state.
@ DT_HISTORY_MERGE_APPEND
static void * _control_import_alloc()
gboolean _create_dir(const char *path)
Creates folders from path. Returns TRUE if success.
static void _control_import_job_cleanup(void *p)
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.
gboolean _copy_file(const char *filename, const char *dest_file_path)
Just copy a file. Returns 1 if success.
static dt_control_import_discarded_handler_t _discarded_files_handler
void dt_import_duplicate_get_dest_name(char *xmp_dest_name, const char *dest_file_path, const int counter)
Gets the computed xmp file name with apropriate number for import copy. It computes a duplicate name ...
int32_t _import_image(const GList *img, dt_control_import_t *data, const char *final_destination, GList **discarded, int *xmps)
process to copy (or not) and import an image to database.
int dt_control_import(dt_control_import_t data)
Process a list of images to import with or without copying the files on an arbitrary hard-drive.
static int32_t _control_import_job_run(dt_job_t *job)
static dt_job_t * _control_import_job_create(dt_control_import_t data)
static void _refresh_progress_counter(dt_job_t *job, const int elements, const int index, const gboolean folder_survey)
Update import progress with wording matching the import origin.
gboolean _file_exist(const char *dest_file_path)
Tests if file exist. Returns 1 if so.
const int32_t _import_job(dt_control_import_t *data, gchar *img_path_to_db)
Add an image entry in the database and returns its imgID.
int _import_copy_xmp(const char *const filename, const gchar *dest_file_path)
Attempt to find all sidecar XMP files along an image file and import (copy) it to destination.
int _import_copy_file(const char *const filename, const char *const dest_file_path, dt_control_import_t *data, gchar *img_path_to_db, size_t pathname_len, GList **discarded)
copy a file to a destination path after checking if everything is allright.
void _write_xmp_id(const char *filename, int32_t imgid)
gchar * _path_cleanup(gchar *path_in)
Replaces separator depending of the current OS and removes whitespaces.
void dt_control_import_set_discarded_files_handler(dt_control_import_discarded_handler_t handler)
int _import_copy_txt(const char *const filename, const char *dest_file_path)
void dt_control_import_data_free(dt_control_import_t *data)
@ DT_IMPORT_ONCONFLICT_UNIQUE
@ DT_IMPORT_ONCONFLICT_OVERWRITE
void(* dt_control_import_discarded_handler_t)(struct dt_control_image_enumerator_t *params)
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.
dt_job_t * dt_control_job_create(dt_job_execute_callback execute, const char *msg,...)
int dt_control_add_job(dt_control_t *control, dt_job_queue_t queue_id, _dt_job_t *job)
void * dt_control_job_get_params(const _dt_job_t *job)
void dt_control_job_set_progress(dt_job_t *job, double value)
void dt_control_job_add_progress(dt_job_t *job, const char *message, gboolean cancellable)
void dt_control_job_set_progress_message(dt_job_t *job, const char *message)
void dt_control_job_set_params(_dt_job_t *job, void *params, dt_job_destroy_callback callback)
void dt_control_job_dispose(_dt_job_t *job)
static const dt_iop_drawlayer_params_t * params
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free_align(ptr)
Release memory from dt_alloc_align() and set ptr to NULL.
static void dt_free_gpointer(gpointer ptr)
g_free() one pointer, with the signature GDestroyNotify wants.
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
#define DT_PATH_MAX
Buffer size for a filesystem path anywhere in Ansel.
int dt_styles_apply_to_image_merge(const char *name, const int style_id, const int32_t newimgid, const dt_history_merge_strategy_t mode, dt_hm_batch_state_t *batch)
int32_t dt_styles_get_id_by_name(const char *name)
char * dt_variables_expand(dt_variables_params_t *params, gchar *source, gboolean iterate)
void dt_variables_params_destroy(dt_variables_params_t *params)
void dt_variables_params_init(dt_variables_params_t **params)
void dt_variables_set_datetime(dt_variables_params_t *params, GDateTime *datetime)
dt_import_onconflict_t on_conflict
GDestroyNotify callback_data_free
void(* file_imported)(const char *source, gboolean success, gpointer user_data)
Optional per-file completion method.
char * target_file_pattern
char * target_subfolder_pattern
Borrowed inputs for one destination expansion.
Job-local numbering and reservation state; table lifetime belongs to the worker.
typedef double((*spd)(unsigned long int wavelength, double TempK))
gchar * dt_cleanup_separators(gchar *string)
gboolean dt_util_dir_exist(const char *dir)
int dt_util_streams_equal(FILE *first, FILE *second)
Compare the remaining bytes of two borrowed binary streams.
gchar * dt_util_path_get_dirname(const gchar *filename)
gchar * dt_util_normalize_path(const gchar *_input)
size_t safe_strlen(const char *str)
check if the string is empty or NULL before calling strlen()
gboolean dt_util_test_writable_dir(const char *path)
gchar * dt_util_remove_whitespace(const gchar *path)