Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
python: First working example
[simgrid.git] / src / xbt / xbt_os_file.cpp
1 /* xbt_os_file.cpp -- portable interface to file-related functions            */
2
3 /* Copyright (c) 2017-2018. The SimGrid Team.
4  * All rights reserved.                                                     */
5
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. */
8
9 #include "xbt/file.hpp" /* this module */
10
11 #ifdef _WIN32
12 #include <windows.h>
13 #endif
14
15 #include <cstring>
16 #include <libgen.h> /* POSIX dirname */
17
18 std::string simgrid::xbt::Path::get_dir_name()
19 {
20   std::string p(path_);
21   char *res = dirname(&p[0]);
22   return std::string(res, strlen(res));
23 }
24
25 std::string simgrid::xbt::Path::get_base_name()
26 {
27   std::string p(path_);
28   char *res = basename(&p[0]);
29   return std::string(res, strlen(res));
30 }