mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 16:32:18 +01:00 
			
		
		
		
	GLocalFile: add _new_from_dirname_and_basename
Add a new internal constructor for GLocalFile (which itself is private). This new constructor allows creating a GLocalFile from a dirname and a basename, assuming that the dirname is already in canonical form and the basename is a regular basename. This will be used for creating GLocalFile instances from the file monitoring code (for signal emissions).
This commit is contained in:
		| @@ -305,6 +305,38 @@ _g_local_file_new (const char *filename) | ||||
|   return G_FILE (local); | ||||
| } | ||||
|  | ||||
| /*< internal > | ||||
|  * g_local_file_new_from_dirname_and_basename: | ||||
|  * @dirname: an absolute, canonical directory name | ||||
|  * @basename: the name of a child inside @dirname | ||||
|  * | ||||
|  * Creates a #GFile from @dirname and @basename. | ||||
|  * | ||||
|  * This is more efficient than pasting the fields together for yourself | ||||
|  * and creating a #GFile from the result, and also more efficient than | ||||
|  * creating a #GFile for the dirname and using g_file_get_child(). | ||||
|  * | ||||
|  * @dirname must be canonical, as per GLocalFile's opinion of what | ||||
|  * canonical means.  This means that you should only pass strings that | ||||
|  * were returned by _g_local_file_get_filename(). | ||||
|  * | ||||
|  * Returns: a #GFile | ||||
|  */ | ||||
| GFile * | ||||
| g_local_file_new_from_dirname_and_basename (const gchar *dirname, | ||||
|                                             const gchar *basename) | ||||
| { | ||||
|   GLocalFile *local; | ||||
|  | ||||
|   g_return_val_if_fail (dirname != NULL, NULL); | ||||
|   g_return_val_if_fail (basename && basename[0] && !strchr (basename, '/'), NULL); | ||||
|  | ||||
|   local = g_object_new (G_TYPE_LOCAL_FILE, NULL); | ||||
|   local->filename = g_build_filename (dirname, basename, NULL); | ||||
|  | ||||
|   return G_FILE (local); | ||||
| } | ||||
|  | ||||
| static gboolean | ||||
| g_local_file_is_native (GFile *file) | ||||
| { | ||||
|   | ||||
| @@ -46,6 +46,9 @@ GFile * _g_local_file_new      (const char *filename); | ||||
|  | ||||
| const char * _g_local_file_get_filename (GLocalFile *file); | ||||
|  | ||||
| GFile * g_local_file_new_from_dirname_and_basename (const char *dirname, | ||||
|                                                     const char *basename); | ||||
|  | ||||
| G_END_DECLS | ||||
|  | ||||
| #endif /* __G_LOCAL_FILE_H__ */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user