diff options
author | David Perry <boolean263@protonmail.com> | 2022-02-09 14:32:28 +0000 |
---|---|---|
committer | A Wireshark GitLab Utility <6629907-ws-gitlab-utility@users.noreply.gitlab.com> | 2022-02-09 14:32:28 +0000 |
commit | 1e0d117eb7ab1ce7f4ff8a4fd6dc2529634d7baa (patch) | |
tree | e7670b02e6c4d49e4f321864e730e0e48433b151 /wiretap | |
parent | f72787e86ff78790559fd5550e98865e225bfb68 (diff) |
Specify directory for temporary captures
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/file_access.c | 4 | ||||
-rw-r--r-- | wiretap/merge.c | 10 | ||||
-rw-r--r-- | wiretap/merge.h | 3 | ||||
-rw-r--r-- | wiretap/wtap.h | 4 |
4 files changed, 12 insertions, 9 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 0839523ac7..2f6d6bf287 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -2395,7 +2395,7 @@ wtap_dump_open(const char *filename, int file_type_subtype, } wtap_dumper * -wtap_dump_open_tempfile(char **filenamep, const char *pfx, +wtap_dump_open_tempfile(const char *tmpdir, char **filenamep, const char *pfx, int file_type_subtype, wtap_compression_type compression_type, const wtap_dump_params *params, int *err, gchar **err_info) { @@ -2426,7 +2426,7 @@ wtap_dump_open_tempfile(char **filenamep, const char *pfx, (void) g_strlcat(sfx, ext, 16); /* Choose a random name for the file */ - fd = create_tempfile(filenamep, pfx, sfx, NULL); + fd = create_tempfile(tmpdir, filenamep, pfx, sfx, NULL); if (fd == -1) { *err = WTAP_ERR_CANT_OPEN; g_free(wdh); diff --git a/wiretap/merge.c b/wiretap/merge.c index cc732d664c..da4e20b585 100644 --- a/wiretap/merge.c +++ b/wiretap/merge.c @@ -1065,11 +1065,11 @@ merge_files_common(const gchar* out_filename, /* normal output mode */ dsb_combined = g_array_new(FALSE, FALSE, sizeof(wtap_block_t)); params.dsbs_growing = dsb_combined; } - if (out_filename) { + if (out_filename && !out_filenamep) { pdh = wtap_dump_open(out_filename, file_type, WTAP_UNCOMPRESSED, ¶ms, err, err_info); - } else if (out_filenamep) { - pdh = wtap_dump_open_tempfile(out_filenamep, pfx, file_type, + } else if (out_filename && out_filenamep) { + pdh = wtap_dump_open_tempfile(out_filename, out_filenamep, pfx, file_type, WTAP_UNCOMPRESSED, ¶ms, err, err_info); } else { @@ -1132,7 +1132,7 @@ merge_files(const gchar* out_filename, const int file_type, * on failure. */ merge_result -merge_files_to_tempfile(gchar **out_filenamep, const char *pfx, +merge_files_to_tempfile(const char *tmpdir, gchar **out_filenamep, const char *pfx, const int file_type, const char *const *in_filenames, const guint in_file_count, const gboolean do_append, const idb_merge_mode mode, guint snaplen, @@ -1145,7 +1145,7 @@ merge_files_to_tempfile(gchar **out_filenamep, const char *pfx, /* no temporary file name yet */ *out_filenamep = NULL; - return merge_files_common(NULL, out_filenamep, pfx, + return merge_files_common(tmpdir, out_filenamep, pfx, file_type, in_filenames, in_file_count, do_append, mode, snaplen, app_name, cb, err, err_info, err_fileno, err_framenum); diff --git a/wiretap/merge.h b/wiretap/merge.h index 4428825a26..699258209c 100644 --- a/wiretap/merge.h +++ b/wiretap/merge.h @@ -144,6 +144,7 @@ merge_files(const gchar* out_filename, const int file_type, /** Merge the given input files to a temporary file * + * @param tmpdir Points to the directory in which to write the temporary file * @param out_filenamep Points to a pointer that's set to point to the * pathname of the temporary file; it's allocated with g_malloc() * @param pfx A string to be used as the prefix for the temporary file name @@ -166,7 +167,7 @@ merge_files(const gchar* out_filename, const int file_type, * @return the frame type */ WS_DLL_PUBLIC merge_result -merge_files_to_tempfile(gchar **out_filenamep, const char *pfx, +merge_files_to_tempfile(const char *tmpdir, gchar **out_filenamep, const char *pfx, const int file_type, const char *const *in_filenames, const guint in_file_count, const gboolean do_append, const idb_merge_mode mode, guint snaplen, diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 6d7fddc895..4b11804f02 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -2023,6 +2023,7 @@ wtap_dumper* wtap_dump_open(const char *filename, int file_type_subtype, /** * @brief Creates a dumper for a temporary file. * + * @param tmpdir Directory in which to create the temporary file. * @param filenamep Points to a pointer that's set to point to the * pathname of the temporary file; it's allocated with g_malloc() * @param pfx A string to be used as the prefix for the temporary file name @@ -2035,7 +2036,8 @@ wtap_dumper* wtap_dump_open(const char *filename, int file_type_subtype, * @return The newly created dumper object, or NULL on failure. */ WS_DLL_PUBLIC -wtap_dumper* wtap_dump_open_tempfile(char **filenamep, const char *pfx, +wtap_dumper* wtap_dump_open_tempfile(const char *tmpdir, char **filenamep, + const char *pfx, int file_type_subtype, wtap_compression_type compression_type, const wtap_dump_params *params, int *err, gchar **err_info); |