2013-11-26 22:53:44 +00:00
|
|
|
/* dirname.c -- return all but the last element in a file name
|
|
|
|
|
2013-11-26 22:57:29 +00:00
|
|
|
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software
|
2013-11-26 22:53:44 +00:00
|
|
|
Foundation, Inc.
|
|
|
|
|
2013-11-26 22:55:28 +00:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
2013-11-26 22:53:44 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2013-11-26 22:55:28 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2013-11-26 22:53:44 +00:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2013-11-26 22:55:28 +00:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2013-11-26 22:53:44 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "dirname.h"
|
|
|
|
|
2013-11-26 22:57:29 +00:00
|
|
|
#include <stdlib.h>
|
2013-11-26 22:53:44 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include "xalloc.h"
|
|
|
|
|
2013-11-26 22:57:29 +00:00
|
|
|
/* Just like mdir_name (dirname-lgpl.c), except, rather than
|
|
|
|
returning NULL upon malloc failure, here, we report the
|
|
|
|
"memory exhausted" condition and exit. */
|
2013-11-26 22:53:44 +00:00
|
|
|
|
|
|
|
char *
|
|
|
|
dir_name (char const *file)
|
|
|
|
{
|
2013-11-26 22:57:29 +00:00
|
|
|
char *result = mdir_name (file);
|
|
|
|
if (!result)
|
|
|
|
xalloc_die ();
|
|
|
|
return result;
|
2013-11-26 22:53:44 +00:00
|
|
|
}
|