3 * A Nautilus extension which offers configurable context menu actions.
5 * Copyright (C) 2005 The GNOME Foundation
6 * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
7 * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
9 * This Program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This Program 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
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public
20 * License along with this Library; see the file COPYING. If not,
21 * write to the Free Software Foundation, Inc., 59 Temple Place,
22 * Suite 330, Boston, MA 02111-1307, USA.
25 * Frederic Ruaudel <grumz@grumz.net>
26 * Rodrigo Moya <rodrigo@gnome-db.org>
27 * Pierre Wieser <pwieser@trychlos.org>
28 * ... and many others (see AUTHORS)
37 #include <glib/gstdio.h>
40 #include <api/na-core-utils.h>
42 #include "nadp-desktop-provider.h"
43 #include "nadp-utils.h"
46 * nadp_utils_gslist_remove_from:
47 * @list: the #GSList from which remove the @string.
48 * @string: the string to be removed.
50 * Removes a @string from a string list, then frees the removed @string.
53 nadp_utils_gslist_remove_from( GSList
*list
, const gchar
*string
)
57 for( is
= list
; is
; is
= is
->next
){
58 const gchar
*istr
= ( const gchar
* ) is
->data
;
59 if( !na_core_utils_str_collate( string
, istr
)){
61 list
= g_slist_delete_link( list
, is
);
73 nadp_utils_uri_delete( const gchar
*uri
)
80 scheme
= g_uri_parse_scheme( uri
);
82 if( !strcmp( scheme
, "file" )){
83 path
= g_filename_from_uri( uri
, NULL
, NULL
);
86 deleted
= na_core_utils_file_delete( path
);
97 * nadp_utils_uri_is_writable:
98 * @uri: the URI of the file to be tested.
100 * Returns: %TRUE if the file is writable, %FALSE else.
102 * Please note that this type of test is subject to race conditions,
103 * as the file may become unwritable after a successful test,
104 * but before the caller has been able to actually write into it.
106 * There is no "super-test". Just try...
109 nadp_utils_uri_is_writable( const gchar
*uri
)
111 static const gchar
*thisfn
= "nadp_utils_uri_is_writable";
113 GError
*error
= NULL
;
117 if( !uri
|| !g_utf8_strlen( uri
, -1 )){
121 file
= g_file_new_for_uri( uri
);
122 info
= g_file_query_info( file
,
123 G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE
"," G_FILE_ATTRIBUTE_STANDARD_TYPE
,
124 G_FILE_QUERY_INFO_NONE
, NULL
, &error
);
127 g_warning( "%s: g_file_query_info error: %s", thisfn
, error
->message
);
128 g_error_free( error
);
129 g_object_unref( file
);
133 writable
= g_file_info_get_attribute_boolean( info
, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE
);
135 g_debug( "%s: %s is not writable", thisfn
, uri
);
138 g_object_unref( info
);