Loading...
Searching...
No Matches
gamspath.h
1
26#ifndef GAMSPATH_H
27#define GAMSPATH_H
28
29#include <filesystem>
30
31namespace gams {
32
34class GAMSPath : public std::filesystem::path
35{
36public:
38 GAMSPath() : std::filesystem::path() {}
39
42 GAMSPath(const char *file) : std::filesystem::path(file) {}
43
46 GAMSPath(const std::string &file) : std::filesystem::path(file) {}
47
50 GAMSPath(const std::filesystem::path &file) : std::filesystem::path(file) {}
51
55 GAMSPath(const std::filesystem::path & dir, const std::string &file) : std::filesystem::path(dir / file){ }
56
59 GAMSPath(const GAMSPath &gpath) : std::filesystem::path(gpath.string()) {}
60
64 GAMSPath &operator=(const GAMSPath &other);
65
69 GAMSPath &operator <<(const std::string &append);
70
74 GAMSPath &operator +=(const std::string &append);
75
79 GAMSPath operator +(const std::string &append);
80
84 GAMSPath operator +(const char *append);
85
90
94 GAMSPath operator /(const std::string &append);
95
99 GAMSPath operator /(const char *append);
100
102 operator std::string();
103
105 std::string toStdString() const;
106
109 const char* c_str() const;
110
114 GAMSPath tempDir(const std::string &tempPath = std::string());
115
119 GAMSPath tempFile(const std::string &tempName = "XXXXXX.tmp");
120
123 void setSuffix(const char *suffix);
124
127 void setSuffix(const std::string &suffix);
128
132 GAMSPath suffix(const std::string &suffix) const;
133
137 GAMSPath suffix(const char *suffix) const;
138
141 GAMSPath up() const;
142
144 std::string suffix() const;
145
147 GAMSPath path() const;
148
150 bool mkDir() const;
151
155
157 void pack();
158
161 bool remove();
162
166 bool rename(const std::string &newFileName);
167
171 bool rename(const char *newFileName);
172
175 bool exists() const;
176
180 static bool exists(const std::string &file);
181
185 static bool exists(const char *file);
186
187};
188
189#ifdef _WIN32
190static thread_local bool seedGenerated;
191#else
192#pragma GCC diagnostic push
193#pragma GCC diagnostic ignored "-Wunused-variable"
194static thread_local bool seedGenerated;
195#pragma GCC diagnostic pop
196#endif
197
198}
199
200#endif // GPATH_H
Represents the GAMS path to a specific file.
Definition: gamspath.h:35
GAMSPath(const GAMSPath &gpath)
Definition: gamspath.h:59
GAMSPath operator/(const GAMSPath &append)
bool rename(const char *newFileName)
GAMSPath suffix(const std::string &suffix) const
GAMSPath(const char *file)
Definition: gamspath.h:42
void pack()
Normalizes the Path to make it comparable by converting it to it's shortest absolute representation.
GAMSPath tempDir(const std::string &tempPath=std::string())
GAMSPath & operator+=(const std::string &append)
void setSuffix(const char *suffix)
GAMSPath(const std::filesystem::path &file)
Definition: gamspath.h:50
bool exists() const
const char * c_str() const
GAMSPath operator+(const std::string &append)
std::string suffix() const
Path suffix.
GAMSPath(const std::filesystem::path &dir, const std::string &file)
Definition: gamspath.h:55
bool rename(const std::string &newFileName)
GAMSPath path() const
Get the GAMSPath.
GAMSPath()
Standard constructor.
Definition: gamspath.h:38
GAMSPath(const std::string &file)
Definition: gamspath.h:46
static bool exists(const char *file)
GAMSPath & operator<<(const std::string &append)
GAMSPath suffix(const char *suffix) const
bool mkDir() const
Create the directory.
std::string toStdString() const
Get the path or file as std::string.
GAMSPath & operator=(const GAMSPath &other)
GAMSPath tempFile(const std::string &tempName="XXXXXX.tmp")
operator std::string()
Converts a std::string to GAMSPath.
static bool exists(const std::string &file)
bool rmDirRecurse()
GAMSPath up() const
void setSuffix(const std::string &suffix)
Definition: gams.h:91