Sort headers using clang-tidy
[geeqie.git] / src / filedata.cc
index 5a73a10..14e7d34 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "main.h"
 #include "filedata.h"
 
-#include "filefilter.h"
+#include <config.h>
+
 #include "cache.h"
-#include "thumb-standard.h"
-#include "ui-fileops.h"
-#include "metadata.h"
-#include "trash.h"
+#include "debug.h"
+#include "filefilter.h"
 #include "histogram.h"
+#include "intl.h"
+#include "main-defines.h"
+#include "main.h"
+#include "metadata.h"
+#include "options.h"
 #include "secure-save.h"
+#include "thumb-standard.h"
+#include "trash.h"
+#include "ui-fileops.h"
 
 #include "exif.h"
 #include "misc.h"
 
 #include <grp.h>
+#include <pwd.h>
 
 #ifdef DEBUG_FILEDATA
 gint global_file_data_count = 0;
@@ -60,9 +67,13 @@ static gboolean filelist_sort_case = TRUE;
 
 gchar *text_from_size(gint64 size)
 {
-       gchar *a, *b;
-       gchar *s, *d;
-       gint l, n, i;
+       gchar *a;
+       gchar *b;
+       gchar *s;
+       gchar *d;
+       gint l;
+       gint n;
+       gint i;
 
        /* what I would like to use is printf("%'d", size)
         * BUT: not supported on every libc :(
@@ -332,7 +343,8 @@ static void file_data_set_path(FileData *fd, const gchar *path)
                file_data_set_collate_keys(fd);
                return;
                }
-       else if (strcmp(fd->name, ".") == 0)
+
+       if (strcmp(fd->name, ".") == 0)
                {
                g_free(fd->path);
                fd->path = remove_level_from_path(path);
@@ -507,7 +519,12 @@ void read_exif_time_data(FileData *file)
                if (tmp)
                        {
                        struct tm time_str;
-                       uint year, month, day, hour, min, sec;
+                       uint year;
+                       uint month;
+                       uint day;
+                       uint hour;
+                       uint min;
+                       uint sec;
 
                        sscanf(tmp, "%4u:%2u:%2u %2u:%2u:%2u", &year, &month, &day, &hour, &min, &sec);
                        time_str.tm_year  = year - 1900;
@@ -545,7 +562,12 @@ void read_exif_time_digitized_data(FileData *file)
                if (tmp)
                        {
                        struct tm time_str;
-                       uint year, month, day, hour, min, sec;
+                       uint year;
+                       uint month;
+                       uint day;
+                       uint hour;
+                       uint min;
+                       uint sec;
 
                        sscanf(tmp, "%4u:%2u:%2u %2u:%2u:%2u", &year, &month, &day, &hour, &min, &sec);
                        time_str.tm_year  = year - 1900;
@@ -586,7 +608,7 @@ void set_exif_time_data_unused(GList *files)
 
        while (files)
                {
-               FileData *file = static_cast<FileData *>(files->data);
+               auto *file = static_cast<FileData *>(files->data);
 
                read_exif_time_data(file);
                files = files->next;
@@ -599,7 +621,7 @@ void set_exif_time_digitized_data_unused(GList *files)
 
        while (files)
                {
-               FileData *file = static_cast<FileData *>(files->data);
+               auto *file = static_cast<FileData *>(files->data);
 
                read_exif_time_digitized_data(file);
                files = files->next;
@@ -613,7 +635,7 @@ void set_rating_data_unused(GList *files)
 
        while (files)
                {
-               FileData *file = static_cast<FileData *>(files->data);
+               auto *file = static_cast<FileData *>(files->data);
                rating_str = metadata_read_string(file, RATING_KEY, METADATA_PLAIN);
                if (rating_str )
                        {
@@ -941,7 +963,8 @@ static void file_data_check_sidecars(const GList *basename_list)
        /* all files in the list have ref count > 0 */
 
        const GList *work;
-       GList *s_work, *new_sidecars;
+       GList *s_work;
+       GList *new_sidecars;
        FileData *parent_fd;
 
        if (!basename_list) return;
@@ -2965,11 +2988,11 @@ static gboolean file_data_perform_delete(FileData *fd)
 {
        if (isdir(fd->path) && !islink(fd->path))
                return rmdir_utf8(fd->path);
-       else
-               if (options->file_ops.safe_delete_enable)
-                       return file_util_safe_unlink(fd->path);
-               else
-                       return unlink_file(fd->path);
+
+       if (options->file_ops.safe_delete_enable)
+               return file_util_safe_unlink(fd->path);
+
+       return unlink_file(fd->path);
 }
 
 gboolean file_data_perform_ci(FileData *fd)
@@ -3236,12 +3259,12 @@ gboolean file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data
 #pragma GCC diagnostic ignored "-Wunused-function"
 gboolean file_data_send_notification_idle_cb_unused(gpointer data)
 {
-       NotifyIdleData *nid = (NotifyIdleData *)data;
+       auto *nid = (NotifyIdleData *)data;
        GList *work = notify_func_list;
 
        while (work)
                {
-               NotifyData *nd = (NotifyData *)work->data;
+               auto *nd = (NotifyData *)work->data;
 
                nd->func(nid->fd, nid->type, nd->data);
                work = work->next;