Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
import_jobs.c File Reference
#include "import_jobs.h"
#include "common/collection.h"
#include "common/datetime.h"
#include "common/exif.h"
#include "common/metadata.h"
#include "control/control.h"
#include "control/jobs/control_jobs.h"
#include <glob.h>
+ Include dependency graph for import_jobs.c:

Functions

gboolean _create_dir (const char *path)
 Creates folders from path. Returns TRUE if success.
 
gchar * _path_cleanup (gchar *path_in)
 Replaces separator depending of the current OS and removes whitespaces.
 
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 _file_exist (const char *dest_file_path)
 Tests if file exist. Returns 1 if so.
 
gboolean _copy_file (const char *filename, const char *dest_file_path)
 Just copy a file. Returns 1 if success.
 
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.
 
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 based on the counter value. The first path in the list ALWAYS become the default xmp. So in case the default xmp was not found, the first one in the list is used as default. Else, it's a duplicate.
 
int _import_copy_xmp (const char *const filename, 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 int index, 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)
 
int32_t _import_image (const GList *img, dt_control_import_t *data, const int index, GList **discarded, int *xmps)
 process to copy (or not) and import an image to database.
 
void _refresh_progress_counter (dt_job_t *job, const int elements, const int index)
 
static int32_t _control_import_job_run (dt_job_t *job)
 
void dt_control_import_data_free (dt_control_import_t *data)
 
static int _discarded_files_popup (dt_control_image_enumerator_t *params)
 
static void _control_import_job_cleanup (void *p)
 
static void_control_import_alloc ()
 
static dt_job_t_control_import_job_create (dt_control_import_t data)
 
void 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.
 

Function Documentation

◆ _control_import_alloc()

static void * _control_import_alloc ( )
static

◆ _control_import_job_cleanup()

◆ _control_import_job_create()

◆ _control_import_job_run()

◆ _copy_file()

gboolean _copy_file ( const char *  filename,
const char *  dest_file_path 
)

Just copy a file. Returns 1 if success.

Parameters
filename
dest_file_path
Returns
gboolean

References DT_DEBUG_IMPORT, and dt_print().

Referenced by _import_copy_file(), and _import_copy_xmp().

◆ _create_dir()

gboolean _create_dir ( const char *  path)

Creates folders from path. Returns TRUE if success.

Parameters
patha valid folders path to create.
Returns
gboolean TRUE on error, FALSE on success

References dt_control_log(), FALSE, and TRUE.

Referenced by _import_copy_file().

◆ _discarded_files_popup()

◆ _file_exist()

gboolean _file_exist ( const char *  dest_file_path)

Tests if file exist. Returns 1 if so.

Parameters
dest_file_path
Returns
gboolean

Referenced by _import_copy_file().

◆ _import_copy_file()

int _import_copy_file ( const char *const  filename,
const int  index,
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.

Parameters
paramsjob informations.
dataimport module information.
img_path_to_dbwill be set to the file path for import.
pathname_lenthe img_path_to_db size.
discardedthe list of file pathes discarded because the target already exists
Returns
int

References _copy_file(), _create_dir(), _file_exist(), _import_copy_xmp(), dt_build_filename_from_pattern(), DT_DEBUG_IMPORT, DT_DEBUG_PRINT, dt_exif_read(), dt_image_init(), dt_print(), dt_util_dir_exist(), dt_util_test_writable_dir(), process(), dt_control_import_t::target_dir, dt_control_import_t::target_file_pattern, dt_control_import_t::target_subfolder_pattern, and TRUE.

Referenced by _import_image().

◆ _import_copy_xmp()

int _import_copy_xmp ( const char *const  filename,
gchar *  dest_file_path 
)

Attempt to find all sidecar XMP files along an image file and import (copy) it to destination.

Parameters
filenamefull path of original image file
dest_file_pathfull path of destination image file
Returns
int number of imported XMP

References _copy_file(), DT_DEBUG_IMPORT, dt_image_find_xmps(), dt_import_duplicate_get_dest_name(), dt_print(), and PATH_MAX.

Referenced by _import_copy_file().

◆ _import_image()

int32_t _import_image ( const GList *  img,
dt_control_import_t data,
const int  index,
GList **  discarded,
int *  xmps 
)

process to copy (or not) and import an image to database.

Parameters
imgthe current image.
datainfo from import module.
indexcurrent loop's index.
Returns
int32_t the imgid of the imported image (or -1 if import failed)

References _import_copy_file(), _import_job(), dt_control_import_t::copy, dt_control_log(), DT_DEBUG_IMPORT, dt_image_read_duplicates(), dt_print(), FALSE, PATH_MAX, and UNKNOWN_IMAGE.

Referenced by _control_import_job_run().

◆ _import_job()

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.

Parameters
datainformations from the import module
img_path_to_dbthe file path to import
Returns
const int32_t

References dt_film_new(), dt_image_import(), dt_util_path_get_dirname(), and FALSE.

Referenced by _import_image().

◆ _path_cleanup()

gchar * _path_cleanup ( gchar *  path_in)

Replaces separator depending of the current OS and removes whitespaces.

Parameters
path
Returns
gchar*

References dt_cleanup_separators(), and dt_util_remove_whitespace().

Referenced by dt_build_filename_from_pattern().

◆ _refresh_progress_counter()

void _refresh_progress_counter ( dt_job_t job,
const int  elements,
const int  index 
)

◆ _write_xmp_id()

void _write_xmp_id ( const char *  filename,
int32_t  imgid 
)

◆ dt_build_filename_from_pattern()

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.

Parameters
filenameFull path of the original file
indexIncremental number in a sequence
imgdt_image_t object. Needs to be inited with EXIF fields prior to calling this function, otherwise EXIF variables are expanded to defaults/fallback.
dataImport options
Returns
gchar* The full path after variables expansion

References _path_cleanup(), dt_control_import_t::base_folder, dt_control_import_t::datetime, DT_DEBUG_PRINT, dt_print(), dt_util_normalize_path(), dt_variables_expand(), dt_variables_params_destroy(), dt_variables_params_init(), dt_variables_set_datetime(), FALSE, dt_control_import_t::jobcode, dt_control_import_t::target_dir, dt_control_import_t::target_file_pattern, dt_control_import_t::target_subfolder_pattern, and UNKNOWN_IMAGE.

Referenced by _import_copy_file(), and _set_test_path().

◆ dt_control_import()

void 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.

Parameters
dataimport informations to transmit through the functions

References _control_import_job_create(), darktable_t::control, darktable, dt_control_add_job(), and DT_JOB_QUEUE_USER_FG.

Referenced by _process_file_list(), and _thumbtable_dnd_import().

◆ dt_control_import_data_free()

◆ dt_import_duplicate_get_dest_name()

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 based on the counter value. The first path in the list ALWAYS become the default xmp. So in case the default xmp was not found, the first one in the list is used as default. Else, it's a duplicate.

Parameters
xmp_dest_namethe destination name.
dest_file_paththe full filename path of the destination image.
counterthe number of duplicates.
Returns
void

References DT_DEBUG_IMPORT, dt_print(), dt_util_normalize_path(), PATH_MAX, and safe_strlen().

Referenced by _import_copy_xmp().