1 /* xbt_os_file.cpp -- portable interface to file-related functions */
3 /* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "src/internal_config.h"
9 #include "xbt/asserts.h"
10 #include "xbt/file.hpp" /* this module */
22 #include <libgen.h> /* POSIX dirname */
24 simgrid::xbt::Path::Path()
28 const char* ret = getcwd(buffer, 2048);
29 xbt_assert(ret == buffer, "Error during getcwd: %s", strerror(errno));
30 path_ = std::string(buffer);
32 path_ = std::string(".");
36 std::string simgrid::xbt::Path::get_dir_name()
39 const char* res = dirname(&p[0]);
40 return std::string(res, strlen(res));
43 std::string simgrid::xbt::Path::get_base_name()
46 const char* res = basename(&p[0]);
47 return std::string(res, strlen(res));