Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions filesystem/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ class path {
return oss.str();
}

std::string string() const {
return str();
}

void set(const std::string &str, path_type type = native_path) {
m_type = type;
if (type == windows_path) {
Expand Down Expand Up @@ -431,4 +435,12 @@ inline bool create_directories(const path& p) {
#endif
}

inline bool exists(const path& p) {
return p.exists();
}

inline bool is_directory(const path& p) {
return p.is_directory();
}

NAMESPACE_END(filesystem)
3 changes: 3 additions & 0 deletions path_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@ int main(int argc, char **argv) {
cout << "some/path.ext:operator==() (unequal) = " << (path("some/path.ext") == path("another/path.ext")) << endl;

cout << "nonexistant:exists = " << path("nonexistant").exists() << endl;
cout << "nonexistant:exists = " << exists(path("nonexistant")) << endl;
cout << "nonexistant:is_file = " << path("nonexistant").is_file() << endl;
cout << "nonexistant:is_directory = " << path("nonexistant").is_directory() << endl;
cout << "nonexistant:filename = " << path("nonexistant").filename() << endl;
cout << "nonexistant:extension = " << path("nonexistant").extension() << endl;
cout << "filesystem/path.h:exists = " << path("filesystem/path.h").exists() << endl;
cout << "filesystem/path.h:exists = " << exists(path("filesystem/path.h")) << endl;
cout << "filesystem/path.h:is_file = " << path("filesystem/path.h").is_file() << endl;
cout << "filesystem/path.h:is_directory = " << path("filesystem/path.h").is_directory() << endl;
cout << "filesystem/path.h:filename = " << path("filesystem/path.h").filename() << endl;
cout << "filesystem/path.h:extension = " << path("filesystem/path.h").extension() << endl;
cout << "filesystem/path.h:make_absolute = " << path("filesystem/path.h").make_absolute() << endl;
cout << "../filesystem:exists = " << path("../filesystem").exists() << endl;
cout << "../filesystem:exists = " << exists(path("../filesystem")) << endl;
cout << "../filesystem:is_file = " << path("../filesystem").is_file() << endl;
cout << "../filesystem:is_directory = " << path("../filesystem").is_directory() << endl;
cout << "../filesystem:extension = " << path("../filesystem").extension() << endl;
Expand Down