Commit 8ebf2031 authored by Davis King's avatar Davis King

Added a file_exists() function.

parent ed4fad06
......@@ -34,6 +34,23 @@ namespace dlib
}
}
// ----------------------------------------------------------------------------------------
bool file_exists (
const std::string& filename
)
{
try
{
dlib::file temp(filename);
return true;
}
catch (file::file_not_found&)
{
return false;
}
}
// ----------------------------------------------------------------------------------------
directory get_parent_directory (
......
......@@ -13,6 +13,12 @@
namespace dlib
{
// ----------------------------------------------------------------------------------------
bool file_exists (
const std::string& filename
);
// ----------------------------------------------------------------------------------------
namespace implementation_details
......
......@@ -10,6 +10,19 @@
namespace dlib
{
// ----------------------------------------------------------------------------------------
bool file_exists (
const std::string& filename
);
/*!
ensures
- if (a file with the given filename exists) then
- returns true
- else
- returns false
!*/
// ----------------------------------------------------------------------------------------
template <typename T>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment