1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
3 /* inotify-sub.c - GVFS Monitor based on inotify.
5 Copyright (C) 2006 John McCutchan
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; if not, see <http://www.gnu.org/licenses/>.
21 John McCutchan <john@johnmccutchan.com>
28 #include "inotify-sub.h"
30 static gboolean is_debug_enabled
= FALSE
;
31 #define IS_W if (is_debug_enabled) g_warning
34 dup_dirname (const gchar
*dirname
)
36 gchar
*d_dirname
= g_strdup (dirname
);
37 size_t len
= strlen (d_dirname
);
39 if (d_dirname
[len
- 1] == '/')
40 d_dirname
[len
- 1] = '\0';
46 _ih_sub_new (const gchar
*dirname
,
47 const gchar
*filename
,
48 gboolean watch_hardlinks
,
51 inotify_sub
*sub
= NULL
;
53 sub
= g_new0 (inotify_sub
, 1);
54 sub
->dirname
= dup_dirname (dirname
);
55 sub
->filename
= g_strdup (filename
);
56 sub
->hardlinks
= watch_hardlinks
;
57 sub
->user_data
= user_data
;
59 IS_W ("new subscription for %s being setup\n", sub
->dirname
);
65 _ih_sub_free (inotify_sub
*sub
)
67 g_free (sub
->dirname
);
68 g_free (sub
->filename
);