Commit 1e7382c7 authored by Jaikrishnan Menon's avatar Jaikrishnan Menon

CPU: Remove codegen directory if it exists

parent abdbe348
...@@ -78,6 +78,12 @@ size_t ngraph::file_util::get_file_size(const string& filename) ...@@ -78,6 +78,12 @@ size_t ngraph::file_util::get_file_size(const string& filename)
void ngraph::file_util::remove_directory(const string& dir) void ngraph::file_util::remove_directory(const string& dir)
{ {
struct stat status;
if (stat(dir.c_str(), &status) == -1)
{
return;
}
file_util::iterate_files(dir, file_util::iterate_files(dir,
[](const string& file, bool is_dir) { [](const string& file, bool is_dir) {
if (is_dir) if (is_dir)
......
...@@ -328,6 +328,7 @@ extern "C" void free_aligned_buffer(void* allocated); ...@@ -328,6 +328,7 @@ extern "C" void free_aligned_buffer(void* allocated);
string output_dir = "cpu_codegen"; string output_dir = "cpu_codegen";
string function_name = m_function->get_name(); string function_name = m_function->get_name();
file_util::remove_directory(output_dir);
file_util::make_directory(output_dir); file_util::make_directory(output_dir);
string filename = file_util::path_join(output_dir, function_name + "_codegen.cpp"); string filename = file_util::path_join(output_dir, function_name + "_codegen.cpp");
ofstream out(filename); ofstream out(filename);
......
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