1 /* xbt_os_file.c -- portable interface to file-related functions */
3 /* Copyright (c) 2007-2010, 2012-2017. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "xbt/sysdep.h"
10 #include "xbt/file.h" /* this module */
12 #include "src/internal_config.h"
18 #include "libgen.h" /* POSIX dirname */
20 /** @brief Returns the directory component of a path (reimplementation of POSIX dirname)
22 * The argument is never modified, and the returned value must be freed after use.
24 char *xbt_dirname(const char *path) {
25 char *tmp = xbt_strdup(path);
26 char *res = xbt_strdup(dirname(tmp));
31 /** @brief Returns the file component of a path (reimplementation of POSIX basename)
33 * The argument is never modified, and the returned value must be freed after use.
35 char *xbt_basename(const char *path) {
36 char *tmp = xbt_strdup(path);
37 char *res = xbt_strdup(basename(tmp));