KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
kratos_filesystem.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Philipp Bucher (https://github.com/philbucher)
11 //
12 
13 #pragma once
14 
15 // System includes
16 #include <filesystem>
17 #include <string>
18 #include <vector>
19 
20 // External includes
21 
22 // Project includes
23 #include "includes/define.h"
24 
25 namespace Kratos {
26 
27 // deprecated namespaces wrongly issue a warning with GCC < 10, hence disabling until removed
28 #if defined(__GNUG__) && __GNUC__ < 10 && !defined(__clang__) && !defined(__INTEL_COMPILER)
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wattributes"
31 #endif
32 
33 namespace KRATOS_DEPRECATED_MESSAGE("Please use std::filesystem directly") filesystem {
34 
35 #if defined(__GNUG__) && __GNUC__ < 10 && !defined(__clang__) && !defined(__INTEL_COMPILER)
36 #pragma GCC diagnostic pop
37 #endif
38 
39 bool KRATOS_API(KRATOS_CORE) exists(const std::string& rPath);
40 
41 bool KRATOS_API(KRATOS_CORE) is_regular_file(const std::string& rPath);
42 
43 bool KRATOS_API(KRATOS_CORE) is_directory(const std::string& rPath);
44 
45 bool KRATOS_API(KRATOS_CORE) create_directory(const std::string& rPath);
46 
47 bool KRATOS_API(KRATOS_CORE) create_directories(const std::string& rPath);
48 
49 bool KRATOS_API(KRATOS_CORE) remove(const std::string& rPath);
50 
51 std::uintmax_t KRATOS_API(KRATOS_CORE) remove_all(const std::string& rPath);
52 
53 void KRATOS_API(KRATOS_CORE) rename(const std::string& rPathFrom, const std::string& rPathTo);
54 
55 std::string KRATOS_API(KRATOS_CORE) parent_path(const std::string& rPath);
56 
57 std::string KRATOS_API(KRATOS_CORE) filename(const std::string& rPath);
58 
59 } // namespace filesystem
60 
61 
62 class KRATOS_API(KRATOS_CORE) FilesystemExtensions
63 {
64 
65 public:
68 
70  FilesystemExtensions(FilesystemExtensions const& rOther) = delete;
71 
74 
75  // helper functions related to filesystem
76 
82  KRATOS_DEPRECATED_MESSAGE("Please use std::filesystem directly")
83  static std::string CurrentWorkingDirectory();
84 
91  KRATOS_DEPRECATED_MESSAGE("Please use the /-operator directly")
92  static std::string JoinPaths(const std::vector<std::string>& rPaths);
93 
100  [[nodiscard]] static std::vector<std::filesystem::path> ListDirectory(const std::filesystem::path& rPath);
101 
107  static void MPISafeCreateDirectories(const std::filesystem::path& rPath);
108 
117  [[nodiscard]] static std::filesystem::path ResolveSymlinks(const std::filesystem::path& rPath);
118 
119 }; // class FilesystemExtensions
120 
121 } // namespace Kratos
Definition: kratos_filesystem.h:63
FilesystemExtensions()=delete
Default constructor.
FilesystemExtensions & operator=(FilesystemExtensions const &rOther)=delete
Assignment operator.
FilesystemExtensions(FilesystemExtensions const &rOther)=delete
Copy constructor.
#define KRATOS_API(...)
Definition: kratos_export_api.h:40
string path
Definition: DEM_run_all_benchmarks_analysis.py:10
void rename(const std::string &rPathFrom, const std::string &rPathTo)
Definition: kratos_filesystem.cpp:69
std::string parent_path(const std::string &rPath)
Definition: kratos_filesystem.cpp:74
bool remove(const std::string &rPath)
Definition: kratos_filesystem.cpp:57
bool create_directory(const std::string &rPath)
Definition: kratos_filesystem.cpp:45
bool exists(const std::string &rPath)
Definition: kratos_filesystem.cpp:27
bool create_directories(const std::string &rPath)
Definition: kratos_filesystem.cpp:51
bool is_regular_file(const std::string &rPath)
Definition: kratos_filesystem.cpp:33
std::uintmax_t remove_all(const std::string &rPath)
Definition: kratos_filesystem.cpp:63
bool is_directory(const std::string &rPath)
Definition: kratos_filesystem.cpp:39
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Kratos::PeriodicInterfaceProcess Process operator(std::istream &rIStream, PeriodicInterfaceProcess &rThis)
input stream function
namespace KRATOS_DEPRECATED_MESSAGE("Please use std::filesystem directly") filesystem
Definition: kratos_filesystem.h:33
string filename
Definition: cube_mesher.py:766
tuple const
Definition: ode_solve.py:403
namespace
Definition: array_1d.h:793