summaryrefslogtreecommitdiff
path: root/glib/gpathbuf.h
blob: b42341998d1930fc5ec3a27b6a9a7ac89f5067f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* gpathbuf.h: A mutable path builder
 *
 * SPDX-FileCopyrightText: 2023  Emmanuele Bassi
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#pragma once

#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
#error "Only <glib.h> can be included directly."
#endif

#include <glib/gtypes.h>

G_BEGIN_DECLS

typedef struct _GPathBuf  GPathBuf;

/**
 * GPathBuf: (copy-func g_path_buf_copy) (free-func g_path_buf_free)
 *
 * A mutable path builder.
 *
 * Since: 2.76
 */
struct _GPathBuf
{
  /*< private >*/
  gpointer dummy[8];
};

/**
 * G_PATH_BUF_INIT:
 *
 * Initializes a #GPathBuf on the stack.
 *
 * A stack-allocated `GPathBuf` must be initialized if it is used
 * together with g_auto() to avoid warnings and crashes if the
 * function returns before calling g_path_buf_init().
 *
 * |[<!-- language="C" -->
 *   g_auto (GPathBuf) buf = G_PATH_BUF_INIT;
 * ]|
 *
 * Since: 2.76
 */
#define G_PATH_BUF_INIT { { NULL, } } \
  GLIB_AVAILABLE_MACRO_IN_2_76

GLIB_AVAILABLE_IN_2_76
GPathBuf *    g_path_buf_new            (void);
GLIB_AVAILABLE_IN_2_76
GPathBuf *    g_path_buf_new_from_path  (const char *path);
GLIB_AVAILABLE_IN_2_76
GPathBuf *    g_path_buf_init           (GPathBuf   *buf);
GLIB_AVAILABLE_IN_2_76
GPathBuf *    g_path_buf_init_from_path (GPathBuf   *buf,
                                         const char *path);
GLIB_AVAILABLE_IN_2_76
void          g_path_buf_clear          (GPathBuf   *buf);
GLIB_AVAILABLE_IN_2_76
char *        g_path_buf_clear_to_path  (GPathBuf   *buf) G_GNUC_WARN_UNUSED_RESULT;
GLIB_AVAILABLE_IN_2_76
void          g_path_buf_free           (GPathBuf   *buf);
GLIB_AVAILABLE_IN_2_76
char *        g_path_buf_free_to_path   (GPathBuf   *buf) G_GNUC_WARN_UNUSED_RESULT;
GLIB_AVAILABLE_IN_2_76
GPathBuf *    g_path_buf_copy           (GPathBuf   *buf);

GLIB_AVAILABLE_IN_2_76
GPathBuf *    g_path_buf_push           (GPathBuf   *buf,
                                         const char *path);
GLIB_AVAILABLE_IN_2_76
gboolean      g_path_buf_pop            (GPathBuf   *buf);

GLIB_AVAILABLE_IN_2_76
gboolean      g_path_buf_set_filename   (GPathBuf   *buf,
                                         const char *file_name);
GLIB_AVAILABLE_IN_2_76
gboolean      g_path_buf_set_extension  (GPathBuf   *buf,
                                         const char *extension);

GLIB_AVAILABLE_IN_2_76
char *        g_path_buf_to_path        (GPathBuf   *buf) G_GNUC_WARN_UNUSED_RESULT;

GLIB_AVAILABLE_IN_2_76
gboolean      g_path_buf_equal          (gconstpointer v1,
                                         gconstpointer v2);

G_END_DECLS