Skip to content

Commit

Permalink
chore: use similar variable/function names
Browse files Browse the repository at this point in the history
  • Loading branch information
hakan-demirli committed Feb 1, 2024
1 parent dd5dc06 commit c1d3288
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions kernel/yosys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,18 +436,18 @@ std::string make_temp_dir(std::string template_str)
#endif
}

bool check_dir_exists(const std::string& path)
bool check_directory_exists(const std::string& dirname)
{
#if defined(_WIN32)
struct _stat info;
if (_stat(path.c_str(), &info) != 0)
if (_stat(dirname.c_str(), &info) != 0)
{
return false;
}
return (info.st_mode & _S_IFDIR) != 0;
#else
struct stat info;
if (stat(path.c_str(), &info) != 0)
if (stat(dirname.c_str(), &info) != 0)
{
return false;
}
Expand Down Expand Up @@ -500,13 +500,13 @@ void remove_directory(std::string dirname)
#endif
}

bool create_directory(const std::string& path)
bool create_directory(const std::string& dirname)
{
#if defined(_WIN32)
int ret = _mkdir(path.c_str());
int ret = _mkdir(dirname.c_str());
#else
mode_t mode = 0755;
int ret = mkdir(path.c_str(), mode);
int ret = mkdir(dirname.c_str(), mode);
#endif
if (ret == 0)
return true;
Expand All @@ -516,26 +516,26 @@ bool create_directory(const std::string& path)
case ENOENT:
// parent didn't exist, try to create it
{
std::string::size_type pos = path.find_last_of('/');
std::string::size_type pos = dirname.find_last_of('/');
if (pos == std::string::npos)
#if defined(_WIN32)
pos = path.find_last_of('\\');
pos = dirname.find_last_of('\\');
if (pos == std::string::npos)
#endif
return false;
if (!create_directory( path.substr(0, pos) ))
if (!create_directory( dirname.substr(0, pos) ))
return false;
}
// now, try to create again
#if defined(_WIN32)
return 0 == _mkdir(path.c_str());
return 0 == _mkdir(dirname.c_str());
#else
return 0 == mkdir(path.c_str(), mode);
return 0 == mkdir(dirname.c_str(), mode);
#endif

case EEXIST:
// done!
return check_dir_exists(path);
return check_directory_exists(dirname);

default:
return false;
Expand Down
4 changes: 2 additions & 2 deletions kernel/yosys.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ std::string get_base_tmpdir();
std::string make_temp_file(std::string template_str = get_base_tmpdir() + "/yosys_XXXXXX");
std::string make_temp_dir(std::string template_str = get_base_tmpdir() + "/yosys_XXXXXX");
bool check_file_exists(std::string filename, bool is_exec = false);
bool check_dir_exists(const std::string& path);
bool check_directory_exists(const std::string& dirname);
bool is_absolute_path(std::string filename);
void remove_directory(std::string dirname);
bool create_directory(const std::string& path);
bool create_directory(const std::string& dirname);
std::string escape_filename_spaces(const std::string& filename);

template<typename T> int GetSize(const T &obj) { return obj.size(); }
Expand Down

0 comments on commit c1d3288

Please sign in to comment.