mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-21 09:27:51 +02:00
new fuction g_dirname() which returns a newlly allocated string.
Tue Jul 14 09:05:18 1998 Tim Janik <timj@gtk.org> * glib.h: * gutils.c: new fuction g_dirname() which returns a newlly allocated string.
This commit is contained in:
@@ -127,6 +127,28 @@ g_basename (const gchar *file_name)
|
||||
return (gchar*) file_name;
|
||||
}
|
||||
|
||||
gchar*
|
||||
g_dirname (const gchar *file_name)
|
||||
{
|
||||
register gchar *base;
|
||||
register guint len;
|
||||
|
||||
g_return_val_if_fail (file_name != NULL, NULL);
|
||||
|
||||
base = strrchr (file_name, '/');
|
||||
if (!base)
|
||||
return g_strdup (".");
|
||||
while (base > file_name && *base == '/')
|
||||
base--;
|
||||
len = (guint) 1 + base - file_name;
|
||||
|
||||
base = g_new (gchar, len + 1);
|
||||
g_memmove (base, file_name, len);
|
||||
base[len] = 0;
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
gchar*
|
||||
g_getcwd (void)
|
||||
{
|
||||
|
Reference in New Issue
Block a user