Add a wrapper for the AddFull document portal api
[glib.git] / gio / kqueue / kqueue-sub.c
blob8b864ba90d5b3dd060b73b7d74b5e7cd8d497e4c
1 /*******************************************************************************
2 Copyright (c) 2011, 2012 Dmitry Matveev <me@dmitrymatveev.co.uk>
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 *******************************************************************************/
23 #include <glib.h>
25 #include "kqueue-sub.h"
27 static gboolean ks_debug_enabled = FALSE;
28 #define KS_W if (ks_debug_enabled) g_warning
30 /**
31 * _kh_sub_new:
32 * @filename: a file path to monitor (will be copied)
33 * @pair_moves: pair moves flag. Refer to #GFileMonitorFlags documentation.
34 * @user_data: user-supplied poiner.
36 * Creates a new subscription object.
38 * Returns: a pointer to a created subscription object.
39 **/
40 kqueue_sub*
41 _kh_sub_new (const gchar *filename,
42 gboolean pair_moves,
43 gpointer user_data)
45 kqueue_sub *sub = g_slice_new (kqueue_sub);
46 g_assert (sub != NULL);
48 sub->filename = g_strdup (filename);
49 sub->pair_moves = pair_moves;
50 sub->user_data = user_data;
51 sub->fd = -1;
52 sub->deps = NULL;
53 /* I think that having such flag in the subscription is not good */
54 sub->is_dir = 0;
56 KS_W ("new subscription for %s being setup\n", sub->filename);
58 return sub;
62 /**
63 * _kh_sub_free:
64 * @sub: a #kqueue_sub
66 * Frees a subscription object and all its associated memory.
67 **/
68 void
69 _kh_sub_free (kqueue_sub *sub)
71 if (sub->deps)
73 dl_free (sub->deps);
74 sub->deps = NULL;
77 g_free (sub->filename);
78 g_slice_free (kqueue_sub, sub);