chore: use similar variable/function names

This commit is contained in:
hakan-demirli 2024-02-02 01:25:58 +03:00
parent dd5dc06863
commit c1d3288654
2 changed files with 14 additions and 14 deletions

View File

@ -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;
}
@ -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;
@ -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;

View File

@ -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(); }