2 * Declarations of routines to create temporary files
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
11 #ifndef __TEMPFILE_H__
12 #define __TEMPFILE_H__
14 #include <wireshark.h>
18 #endif /* __cplusplus */
21 * Convenience function for temporary file creation.
25 * Create a tempfile with the given prefix (e.g. "wireshark"). The path
26 * is created using g_file_open_tmp.
28 * @param tempdir [in] If not NULL, the directory in which to create the file.
29 * @param namebuf [in,out] If not NULL, receives the full path of the temp file.
31 * @param pfx [in] A prefix for the temporary file.
32 * @param sfx [in] A file extension for the temporary file. NULL can be passed
33 * if no file extension is needed
34 * @param err [out] Any error returned by g_file_open_tmp. May be NULL.
35 * @return The file descriptor of the new tempfile, from mkstemps().
37 WS_DLL_PUBLIC
int create_tempfile(const char *tempdir
, char **namebuf
, const char *pfx
, const char *sfx
, GError
**err
);
40 * Create a tempfile with the given parent directory (e.g. "/my/private/tmp"). The path
41 * is created using g_mkdtemp.
43 * @param parent_dir [in] If not NULL, the parent directory in which to create the subdirectory,
44 * otherwise the system temporary directory is used.
45 * @param tmpl [in] A template for the temporary directory.
46 * @param err [out] Any error returned by g_mkdtemp. May be NULL.
47 * @return The full path of the temporary directory or NULL on error. Must be g_freed.
49 WS_DLL_PUBLIC
char *create_tempdir(const char *parent_dir
, const char *tmpl
, GError
**err
);
53 #endif /* __cplusplus */
55 #endif /* __TEMPFILE_H__ */