Commit 23c74af8 authored by Adrià Arrufat's avatar Adrià Arrufat Committed by Davis E. King
Browse files

Add directory_exists

parent 9bb1b6f7
...@@ -51,6 +51,23 @@ namespace dlib ...@@ -51,6 +51,23 @@ namespace dlib
} }
} }
// ----------------------------------------------------------------------------------------
bool directory_exists (
const std::string& dirname
)
{
try
{
dlib::directory temp(dirname);
return true;
}
catch (directory::dir_not_found&)
{
return false;
}
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
directory get_parent_directory ( directory get_parent_directory (
...@@ -70,7 +87,7 @@ namespace dlib ...@@ -70,7 +87,7 @@ namespace dlib
return directory(); return directory();
std::string::size_type pos = f.full_name().find_last_of("\\/"); std::string::size_type pos = f.full_name().find_last_of("\\/");
if (pos == std::string::npos) if (pos == std::string::npos)
return directory(); return directory();
...@@ -116,6 +133,3 @@ namespace dlib ...@@ -116,6 +133,3 @@ namespace dlib
} }
#endif // DLIB_DIR_NAV_EXTENSIONs_CPP_ #endif // DLIB_DIR_NAV_EXTENSIONs_CPP_
...@@ -19,6 +19,12 @@ namespace dlib ...@@ -19,6 +19,12 @@ namespace dlib
const std::string& filename const std::string& filename
); );
// ----------------------------------------------------------------------------------------
bool directory_exists (
const std::string& dirname
);
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
namespace implementation_details namespace implementation_details
......
...@@ -23,6 +23,19 @@ namespace dlib ...@@ -23,6 +23,19 @@ namespace dlib
- returns false - returns false
!*/ !*/
// ----------------------------------------------------------------------------------------
bool directory_exists (
const std::string& dirname
);
/*!
ensures
- if (a directory with the given filename exists) then
- returns true
- else
- returns false
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template <typename T> template <typename T>
......
...@@ -595,6 +595,10 @@ ...@@ -595,6 +595,10 @@
<name>file_exists</name> <name>file_exists</name>
<link>dlib/dir_nav/dir_nav_extensions_abstract.h.html#file_exists</link> <link>dlib/dir_nav/dir_nav_extensions_abstract.h.html#file_exists</link>
</item> </item>
<item>
<name>directory_exists</name>
<link>dlib/dir_nav/dir_nav_extensions_abstract.h.html#directory_exists</link>
</item>
<item> <item>
<name>select_oldest_file</name> <name>select_oldest_file</name>
<link>dlib/dir_nav/dir_nav_extensions_abstract.h.html#select_oldest_file</link> <link>dlib/dir_nav/dir_nav_extensions_abstract.h.html#select_oldest_file</link>
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<current> <current>
New Features and Improvements: New Features and Improvements:
- Added Beta distribution to dlib::rand. - Added Beta distribution to dlib::rand.
- Added directory_exists.
- Deep learning tooling: - Deep learning tooling:
- Added ReOrg layer. - Added ReOrg layer.
- Added visitor to draw network architectures using the DOT language. - Added visitor to draw network architectures using the DOT language.
......
...@@ -1094,6 +1094,7 @@ ...@@ -1094,6 +1094,7 @@
<term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="get_files_in_directory_tree" include="dlib/dir_nav.h"/> <term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="get_files_in_directory_tree" include="dlib/dir_nav.h"/>
<term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="get_parent_directory" include="dlib/dir_nav.h"/> <term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="get_parent_directory" include="dlib/dir_nav.h"/>
<term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="file_exists" include="dlib/dir_nav.h"/> <term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="file_exists" include="dlib/dir_nav.h"/>
<term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="directory_exists" include="dlib/dir_nav.h"/>
<term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="select_oldest_file" include="dlib/dir_nav.h"/> <term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="select_oldest_file" include="dlib/dir_nav.h"/>
<term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="select_newest_file" include="dlib/dir_nav.h"/> <term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="select_newest_file" include="dlib/dir_nav.h"/>
<term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="match_ending" include="dlib/dir_nav.h"/> <term file="dlib/dir_nav/dir_nav_extensions_abstract.h.html" name="match_ending" include="dlib/dir_nav.h"/>
......
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