Skip to content

Commit

Permalink
Minor code clean-up.
Browse files Browse the repository at this point in the history
  • Loading branch information
TurboGit committed Dec 27, 2021
1 parent 576b84e commit b66b278
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/common/import_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ static void _import_session_cleanup_filmroll(dt_import_session_t *self)

static gboolean _import_session_initialize_filmroll(dt_import_session_t *self, const char *path)
{
int32_t film_id;

/* cleanup of previously used filmroll */
_import_session_cleanup_filmroll(self);

Expand All @@ -80,7 +78,7 @@ static gboolean _import_session_initialize_filmroll(dt_import_session_t *self, c

/* open one or initialize a filmroll for the session */
self->film = (dt_film_t *)g_malloc0(sizeof(dt_film_t));
film_id = dt_film_new(self->film, path);
const int32_t film_id = dt_film_new(self->film, path);
if(film_id == 0)
{
fprintf(stderr, "[import_session] Failed to initialize film roll.\n");
Expand Down Expand Up @@ -250,31 +248,29 @@ const char *dt_import_session_name(struct dt_import_session_t *self)
*/
const char *dt_import_session_filename(struct dt_import_session_t *self, gboolean use_filename)
{
const char *path;
char *fname, *previous_fname;
gchar *pattern;
gchar *result_fname;
gchar *result_fname = NULL;

/* expand next filename */
g_free((void *)self->current_filename);
self->current_filename = NULL;

pattern = _import_session_filename_pattern();
char *pattern = _import_session_filename_pattern();
if(pattern == NULL)
{
fprintf(stderr, "[import_session] Failed to get session filaname pattern.\n");
return NULL;
}

/* verify that expanded path and filename yields a unique file */
path = dt_import_session_path(self, TRUE);
const char *path = dt_import_session_path(self, TRUE);

if(use_filename)
result_fname = g_strdup(self->vp->filename);
else
result_fname = dt_variables_expand(self->vp, pattern, TRUE);

previous_fname = fname = g_build_path(G_DIR_SEPARATOR_S, path, result_fname, (char *)NULL);
char *fname = g_build_path(G_DIR_SEPARATOR_S, path, result_fname, (char *)NULL);
char *previous_fname = fname;
if(g_file_test(fname, G_FILE_TEST_EXISTS) == TRUE)
{
fprintf(stderr, "[import_session] File %s exists.\n", fname);
Expand Down Expand Up @@ -313,8 +309,6 @@ const char *dt_import_session_filename(struct dt_import_session_t *self, gboolea

static const char *_import_session_path(struct dt_import_session_t *self, gboolean current)
{
gchar *pattern;
char *new_path;
const gboolean currentok = dt_util_test_writable_dir(self->current_path);
fprintf(stderr, " _import_session_path testing `%s' %i", self->current_path, currentok);

Expand All @@ -327,14 +321,14 @@ static const char *_import_session_path(struct dt_import_session_t *self, gboole
return NULL;
}
/* check if expanded path differs from current */
pattern = _import_session_path_pattern();
gchar *pattern = _import_session_path_pattern();
if(pattern == NULL)
{
fprintf(stderr, "[import_session] Failed to get session path pattern.\n");
return NULL;
}

new_path = dt_variables_expand(self->vp, pattern, FALSE);
char *new_path = dt_variables_expand(self->vp, pattern, FALSE);
g_free(pattern);

/* did the session path change ? */
Expand Down

0 comments on commit b66b278

Please sign in to comment.