Skip to content
Open
Changes from 1 commit
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
24 changes: 24 additions & 0 deletions path_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,41 @@ 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;
try
{
cout << "nonexistant:file_size = " << path("nonexistant").file_size() << endl;
}
catch(std::runtime_error e)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just be catch(std::exception &e)

{
cout << "<file does not exist>" << 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;
try
{
cout << "filesystem/path.h:file_size = " << path("filesystem/path.h").file_size() << endl;
}
catch(std::runtime_error e)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here catch(std::exception &e).

{
cout << "<file does not exist>" << endl;
}
cout << "filesystem/path.h:exists = " << path("filesystem/path.h").exists() << 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;
try
{
cout << "../filesystem:file_size = " << path("../filesystem").file_size() << endl;
}
catch(std::runtime_error e)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

{
cout << "<file does not exist>" << endl;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should include "../filesystem:file_size = ".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part of the try block actually gets executed
output looks like you would expect:

nonexistant:file_size = <file does not exist>

}
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