Coverage Report

Created: 2025-07-23 08:13

/src/pango/subprojects/glib/gio/inotify/inotify-sub.c
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
2
3
/* inotify-sub.c - GVFS Monitor based on inotify.
4
5
   Copyright (C) 2006 John McCutchan
6
7
   SPDX-License-Identifier: LGPL-2.1-or-later
8
9
   This library is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU Lesser General Public
11
   License as published by the Free Software Foundation; either
12
   version 2.1 of the License, or (at your option) any later version.
13
14
   This library is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
   Lesser General Public License for more details.
18
19
   You should have received a copy of the GNU Lesser General Public License
20
   along with this library; if not, see <http://www.gnu.org/licenses/>.
21
22
   Authors: 
23
     John McCutchan <john@johnmccutchan.com>
24
*/
25
26
#include "config.h"
27
#include <string.h>
28
#include <glib.h>
29
30
#include "inotify-sub.h"
31
32
static gboolean is_debug_enabled = FALSE;
33
0
#define IS_W if (is_debug_enabled) g_warning
34
35
static gchar*
36
dup_dirname (const gchar *dirname)
37
0
{
38
0
  gchar *d_dirname = g_strdup (dirname);
39
0
  size_t len = strlen (d_dirname);
40
  
41
0
  if (len > 1 && d_dirname[len - 1] == '/')
42
0
    d_dirname[len - 1] = '\0';
43
  
44
0
  return d_dirname;
45
0
}
46
47
inotify_sub*
48
_ih_sub_new (const gchar *dirname, 
49
             const gchar *basename,
50
             const gchar *filename,
51
             gpointer     user_data)
52
0
{
53
0
  inotify_sub *sub = NULL;
54
  
55
0
  sub = g_new0 (inotify_sub, 1);
56
57
0
  if (filename)
58
0
    {
59
0
      sub->dirname = g_path_get_dirname (filename);
60
0
      sub->filename = g_path_get_basename (filename);
61
0
      sub->hardlinks = TRUE;
62
0
    }
63
0
  else
64
0
    {
65
0
      sub->dirname = dup_dirname (dirname);
66
0
      sub->filename = g_strdup (basename);
67
0
      sub->hardlinks = FALSE;
68
0
    }
69
70
0
  sub->user_data = user_data;
71
72
0
  IS_W ("new subscription for %s being setup\n", sub->dirname);
73
  
74
0
  return sub;
75
0
}
76
77
void
78
_ih_sub_free (inotify_sub *sub)
79
0
{
80
0
  g_free (sub->dirname);
81
0
  g_free (sub->filename);
82
0
  g_free (sub);
83
0
}