summaryrefslogtreecommitdiff
path: root/src/gallery-utils.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2009-04-11 15:43:15 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2009-04-11 15:43:15 +0200
commit9c2c964727e4a484acf7f97267a3cf1c8fbacd89 (patch)
tree261f5ffe6954aaecb2f7ad29edfa459ae0971148 /src/gallery-utils.c
parent6a54c7817bb71fde9234e7b89e87f1f349920ea1 (diff)
downloadcataract-9c2c964727e4a484acf7f97267a3cf1c8fbacd89.tar.xz
Print statistics in verbose mode
Diffstat (limited to 'src/gallery-utils.c')
-rw-r--r--src/gallery-utils.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/gallery-utils.c b/src/gallery-utils.c
index 3e6c30a..8ec258a 100644
--- a/src/gallery-utils.c
+++ b/src/gallery-utils.c
@@ -23,6 +23,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <utime.h>
+#include <stats.h>
#include "gallery-utils.h"
@@ -101,13 +102,13 @@ copy_file (const char *src, const char *dst)
fin = fopen (src, "r");
if (fin == NULL) {
- fprintf (stderr, "copy_file: error reading file \"%s\": %s\n", src, strerror (errno));
+ log_error ("copy_file: error reading file \"%s\": %s\n", src, strerror (errno));
return FALSE;
}
fout = fopen (dst, "w");
if (fout == NULL) {
- fprintf (stderr, "copy_file: error writing to file \"%s\": %s\n", dst, strerror (errno));
+ log_error ("copy_file: error writing to file \"%s\": %s\n", dst, strerror (errno));
fclose (fin);
return FALSE;
}
@@ -120,7 +121,7 @@ copy_file (const char *src, const char *dst)
size_r = fread (buffer, 1, BUFFER_SIZE, fin);
written = fwrite (buffer, 1, size_r, fout);
if (written < size_r) {
- fprintf (stderr, "copy_file: error writing to file \"%s\": %s\n", dst, strerror (errno));
+ log_error ("copy_file: error writing to file \"%s\": %s\n", dst, strerror (errno));
break;
}
}
@@ -132,7 +133,7 @@ copy_file (const char *src, const char *dst)
/* copy timestamps */
memset (&st, 0, sizeof (st));
if (stat (src, &st) == -1) {
- fprintf (stderr, "copy_file: cannot stat source file \"%s\": %s\n", src, strerror (errno));
+ log_error ("copy_file: cannot stat source file \"%s\": %s\n", src, strerror (errno));
return TRUE;
}
@@ -140,7 +141,7 @@ copy_file (const char *src, const char *dst)
ut.actime = st.st_atime;
ut.modtime = st.st_mtime;
if (utime (dst, &ut) == -1)
- fprintf (stderr, "copy_file: cannot set timestamps on target file \"%s\": %s\n", dst, strerror (errno));
+ log_error ("copy_file: cannot set timestamps on target file \"%s\": %s\n", dst, strerror (errno));
return TRUE;
}
@@ -268,7 +269,7 @@ remove_tags (char **str, const char *tag_begin, const char *tag_end)
else
{
/* break in case of malformed tag structure, avoid endless loop */
- fprintf (stderr, "remove_tags: malformed tag structure detected, strange things may happen\n");
+ log_error ("remove_tags: malformed tag structure detected, strange things may happen\n");
break;
}
}
@@ -308,3 +309,20 @@ extract_file_ext (const char *filename)
return strrchr (filename, '.') + 1;
}
+
+
+/*
+ * log_error: prints an error and increments stats
+ */
+/* this function can possibly store error in some list and print them all at the end again */
+void
+log_error (const gchar *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ vfprintf (stderr, format, args);
+ va_end (args);
+
+ stats_errors_inc ();
+}