|
|
4b6aa8 |
From 117345107d77ebcea926aa339a572fa5de30fb95 Mon Sep 17 00:00:00 2001
|
|
|
4b6aa8 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
4b6aa8 |
Date: Fri, 12 Dec 2014 09:17:59 +0100
|
|
|
4b6aa8 |
Subject: [PATCH] dump_dir: introduce dd_copy_file()
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Related to abrt/abrt#548
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
4b6aa8 |
---
|
|
|
4b6aa8 |
src/include/dump_dir.h | 1 +
|
|
|
4b6aa8 |
src/lib/create_dump_dir.c | 10 +---------
|
|
|
4b6aa8 |
src/lib/dump_dir.c | 16 ++++++++++++++++
|
|
|
4b6aa8 |
3 files changed, 18 insertions(+), 9 deletions(-)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
diff --git a/src/include/dump_dir.h b/src/include/dump_dir.h
|
|
|
4b6aa8 |
index fff23f2..84cabbf 100644
|
|
|
4b6aa8 |
--- a/src/include/dump_dir.h
|
|
|
4b6aa8 |
+++ b/src/include/dump_dir.h
|
|
|
4b6aa8 |
@@ -96,6 +96,7 @@ char* dd_load_text_ext(const struct dump_dir *dd, const char *name, unsigned fla
|
|
|
4b6aa8 |
char* dd_load_text(const struct dump_dir *dd, const char *name);
|
|
|
4b6aa8 |
void dd_save_text(struct dump_dir *dd, const char *name, const char *data);
|
|
|
4b6aa8 |
void dd_save_binary(struct dump_dir *dd, const char *name, const char *data, unsigned size);
|
|
|
4b6aa8 |
+int dd_copy_file(struct dump_dir *dd, const char *name, const char *source_path);
|
|
|
4b6aa8 |
/* Returns value less than 0 if any error occured; otherwise returns size of an
|
|
|
4b6aa8 |
* item in Bytes. If an item does not exist returns 0 instead of an error
|
|
|
4b6aa8 |
* value.
|
|
|
4b6aa8 |
diff --git a/src/lib/create_dump_dir.c b/src/lib/create_dump_dir.c
|
|
|
4b6aa8 |
index d683b8e..a96f7bd 100644
|
|
|
4b6aa8 |
--- a/src/lib/create_dump_dir.c
|
|
|
4b6aa8 |
+++ b/src/lib/create_dump_dir.c
|
|
|
4b6aa8 |
@@ -101,15 +101,7 @@ struct dump_dir *create_dump_dir_from_problem_data_ext(problem_data_t *problem_d
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
if (value->flags & CD_FLAG_BIN)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
- char *dest = concat_path_file(dd->dd_dirname, name);
|
|
|
4b6aa8 |
- log_info("copying '%s' to '%s'", value->content, dest);
|
|
|
4b6aa8 |
- off_t copied = copy_file(value->content, dest, DEFAULT_DUMP_DIR_MODE | S_IROTH);
|
|
|
4b6aa8 |
- if (copied < 0)
|
|
|
4b6aa8 |
- error_msg("Can't copy %s to %s", value->content, dest);
|
|
|
4b6aa8 |
- else
|
|
|
4b6aa8 |
- log_info("copied %li bytes", (unsigned long)copied);
|
|
|
4b6aa8 |
- free(dest);
|
|
|
4b6aa8 |
-
|
|
|
4b6aa8 |
+ dd_copy_file(dd, name, value->content);
|
|
|
4b6aa8 |
continue;
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
|
|
|
4b6aa8 |
index 1e6ce64..d7ddec7 100644
|
|
|
4b6aa8 |
--- a/src/lib/dump_dir.c
|
|
|
4b6aa8 |
+++ b/src/lib/dump_dir.c
|
|
|
4b6aa8 |
@@ -1487,6 +1487,22 @@ int dd_mark_as_notreportable(struct dump_dir *dd, const char *reason)
|
|
|
4b6aa8 |
return 0;
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
+int dd_copy_file(struct dump_dir *dd, const char *name, const char *source_path)
|
|
|
4b6aa8 |
+{
|
|
|
4b6aa8 |
+ char *dest = concat_path_file(dd->dd_dirname, name);
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+ log_debug("copying '%s' to '%s'", source_path, dest);
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+ off_t copied = copy_file(source_path, dest, DEFAULT_DUMP_DIR_MODE | S_IROTH);
|
|
|
4b6aa8 |
+ if (copied < 0)
|
|
|
4b6aa8 |
+ error_msg("Can't copy %s to %s", source_path, dest);
|
|
|
4b6aa8 |
+ else
|
|
|
4b6aa8 |
+ log_debug("copied %li bytes", (unsigned long)copied);
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+ free(dest);
|
|
|
4b6aa8 |
+ return copied < 0;
|
|
|
4b6aa8 |
+}
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
/* flags - for future needs */
|
|
|
4b6aa8 |
int dd_create_archive(struct dump_dir *dd, const char *archive_name,
|
|
|
4b6aa8 |
const_string_vector_const_ptr_t exclude_elements, int flags)
|
|
|
4b6aa8 |
--
|
|
|
4b6aa8 |
1.8.3.1
|
|
|
4b6aa8 |
|