Skip to content

Commit

Permalink
bug fix for directory creation when the input is an empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
tangxifan committed Jun 25, 2020
1 parent e2d3ac7 commit b36da17
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libopenfpga/libopenfpgautil/src/openfpga_digest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ std::string format_dir_path(const std::string& dir_path_to_format) {
char legal_back_slash = '\\';
#endif

/* Return an empty string if the input is empty */
if (true == formatted_dir_path.empty()) {
return formatted_dir_path;
}

/* Replace "\" with "/" */
std::replace(formatted_dir_path.begin(), formatted_dir_path.end(), illegal_back_slash, legal_back_slash);

Expand Down Expand Up @@ -123,8 +128,8 @@ bool create_dir_path(const std::string& dir_path,
const bool& verbose) {
/* Give up if the path is empty */
if (true == dir_path.empty()) {
VTR_LOG_ERROR("Directory path is empty and nothing will be created.\n");
return false;
VTR_LOG_WARN("Directory path is empty and nothing will be created.\n");
return true;
}

/* Try to create a directory */
Expand Down Expand Up @@ -170,8 +175,8 @@ static
bool rec_create_dir_path(const std::string& dir_path) {
/* Give up if the path is empty */
if (true == dir_path.empty()) {
VTR_LOG_ERROR("Directory path is empty and nothing will be created.\n");
return false;
VTR_LOG_WARN("Directory path is empty and nothing will be created.\n");
return true;
}

/* Try to find the positions of all the slashes
Expand Down

0 comments on commit b36da17

Please sign in to comment.