GEOSX
Path.hpp
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 Total, S.A
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
15 #ifndef GEOSX_COMMON_PATH_HPP
16 #define GEOSX_COMMON_PATH_HPP
17 
18 // System includes
19 #include <string>
20 #include <vector>
21 
22 namespace geosx
23 {
30 class Path : public std::string
31 {
32 public:
33 
35  Path():
36  std::string()
37  {}
38 
43  Path( Path const & src ):
44  std::string( src )
45  {}
46 
49  {}
50 
56  Path & operator=( Path const & rhs )
57  {
58  std::string::operator=( rhs );
59  return *this;
60  }
61 
62  using std::string::string;
63 
71  {
72  static std::string m_pathPrefix;
73  return m_pathPrefix;
74  }
75 };
76 
82 void getAbsolutePath( std::string const & path, std::string & absolutePath );
83 
90 bool isAbsolutePath( const std::string & path );
91 
98 std::istream & operator>>( std::istream & is, Path & p );
99 
106 void splitPath( std::string const & path, std::string & dirName, std::string & baseName );
107 
114 void readDirectory( std::string const & path, std::vector< std::string > & files );
115 
122 void makeDirsForPath( std::string const & path );
123 
124 } /* end namespace geosx */
125 
126 
127 #endif
void splitPath(std::string const &path, std::string &dirName, std::string &baseName)
Split the path in two parts : directory name and file name.
Class describing a file Path.
Definition: Path.hpp:30
Path()
Default constructor.
Definition: Path.hpp:35
void getAbsolutePath(std::string const &path, std::string &absolutePath)
Gets the absolute path of a file.
std::istream & operator>>(std::istream &is, Path &p)
Operator use with the class Path while parsing the XML file.
bool isAbsolutePath(const std::string &path)
Tells wether the path is absolute of not.
static std::string & pathPrefix()
Get the path prefix of the file.
Definition: Path.hpp:70
void readDirectory(std::string const &path, std::vector< std::string > &files)
List all the files of one directory.
Path & operator=(Path const &rhs)
Copy Constructor.
Definition: Path.hpp:56
~Path()
Destructor.
Definition: Path.hpp:48
std::string string
String type.
Definition: DataTypes.hpp:131
Path(Path const &src)
Copy constructor, creates a copy of src.
Definition: Path.hpp:43
void makeDirsForPath(std::string const &path)
Make directories for path.