LCOV - code coverage report
Current view: top level - gio/inotify - inotify-sub.c (source / functions) Coverage Total Hit
Test: unnamed Lines: 95.8 % 24 23
Test Date: 2024-11-26 05:23:01 Functions: 100.0 % 3 3
Branches: - 0 0

             Branch data     Line data    Source code
       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                 :             : #define IS_W if (is_debug_enabled) g_warning
      34                 :             : 
      35                 :             : static gchar*
      36                 :         675 : dup_dirname (const gchar *dirname)
      37                 :             : {
      38                 :         675 :   gchar *d_dirname = g_strdup (dirname);
      39                 :         675 :   size_t len = strlen (d_dirname);
      40                 :             :   
      41                 :         675 :   if (len > 1 && d_dirname[len - 1] == '/')
      42                 :           0 :     d_dirname[len - 1] = '\0';
      43                 :             :   
      44                 :         675 :   return d_dirname;
      45                 :             : }
      46                 :             : 
      47                 :             : inotify_sub*
      48                 :         676 : _ih_sub_new (const gchar *dirname, 
      49                 :             :              const gchar *basename,
      50                 :             :              const gchar *filename,
      51                 :             :              gpointer     user_data)
      52                 :             : {
      53                 :         676 :   inotify_sub *sub = NULL;
      54                 :             :   
      55                 :         676 :   sub = g_new0 (inotify_sub, 1);
      56                 :             : 
      57                 :         676 :   if (filename)
      58                 :             :     {
      59                 :           1 :       sub->dirname = g_path_get_dirname (filename);
      60                 :           1 :       sub->filename = g_path_get_basename (filename);
      61                 :           1 :       sub->hardlinks = TRUE;
      62                 :             :     }
      63                 :             :   else
      64                 :             :     {
      65                 :         675 :       sub->dirname = dup_dirname (dirname);
      66                 :         675 :       sub->filename = g_strdup (basename);
      67                 :         675 :       sub->hardlinks = FALSE;
      68                 :             :     }
      69                 :             : 
      70                 :         676 :   sub->user_data = user_data;
      71                 :             : 
      72                 :         676 :   IS_W ("new subscription for %s being setup\n", sub->dirname);
      73                 :             :   
      74                 :         676 :   return sub;
      75                 :             : }
      76                 :             : 
      77                 :             : void
      78                 :         484 : _ih_sub_free (inotify_sub *sub)
      79                 :             : {
      80                 :         484 :   g_free (sub->dirname);
      81                 :         484 :   g_free (sub->filename);
      82                 :         484 :   g_free (sub);
      83                 :         484 : }
        

Generated by: LCOV version 2.0-1