Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / include / xbt / file.hpp
1 /* Copyright (c) 2017-2022. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef XBT_FILE_HPP
7 #define XBT_FILE_HPP
8
9 #include <string>
10 #include <xbt/base.h>
11
12 namespace simgrid {
13 namespace xbt {
14
15 class Path {
16 public:
17   /** Build a path from the current working directory (CWD) */
18   explicit Path();
19   /** Build a path from the provided parameter */
20   explicit Path(const char* path): path_(path) {}
21   /** Build a path from the provided parameter */
22   explicit Path(const std::string& path) : path_(path) {}
23
24   /** @brief Returns the full path name */
25   const std::string& get_name() const { return path_; }
26   /** @brief Returns the directory component of a path (reimplementation of POSIX dirname) */
27   std::string get_dir_name() const;
28   /** @brief Returns the file component of a path (reimplementation of POSIX basename) */
29   std::string get_base_name() const;
30
31 private:
32   std::string path_;
33 };
34 }}
35
36 #endif                          /* XBT_FILE_HPP */