Replaced boost filesystem operations with linux system calls (#125)

* Replaced boost filesystem operations with linux syscalls
* Removed boost filesystem dependency from CMAKE
This commit is contained in:
Chalith Desaman
2020-09-23 12:49:06 +05:30
committed by GitHub
parent 91122474a1
commit 3e2b7dbcfa
8 changed files with 491 additions and 375 deletions

View File

@@ -68,16 +68,16 @@ namespace conf
*/
int create_contract()
{
if (boost::filesystem::exists(ctx.contract_dir))
if (util::is_dir_exists(ctx.contract_dir))
{
std::cout << "Contract dir already exists. Cannot create contract at the same location.\n";
return -1;
}
boost::filesystem::create_directories(ctx.config_dir);
boost::filesystem::create_directories(ctx.hist_dir);
boost::filesystem::create_directories(ctx.state_rw_dir);
boost::filesystem::create_directories(ctx.log_dir);
// Recursivly create contract directories.
util::create_dir_tree_recursive(ctx.config_dir);
util::create_dir_tree_recursive(ctx.hist_dir);
util::create_dir_tree_recursive(ctx.state_rw_dir);
//Create config file with default settings.
@@ -134,8 +134,11 @@ namespace conf
// resolving the path through realpath will remove any trailing slash if present
basedir = util::realpath(basedir);
exepath = util::realpath(exepath);
// Take the parent directory path.
ctx.exe_dir = dirname(exepath.data());
ctx.exe_dir = boost::filesystem::path(util::realpath(exepath)).parent_path().string();
ctx.websocketd_exe_path = ctx.exe_dir + "/" + "websocketd";
ctx.websocat_exe_path = ctx.exe_dir + "/" + "websocat";
ctx.hpfs_exe_path = ctx.exe_dir + "/" + "hpfs";
@@ -507,7 +510,7 @@ namespace conf
for (const std::string &path : paths)
{
if (!boost::filesystem::exists(path))
if (!util::is_file_exists(path) && !util::is_dir_exists(path))
{
if (path == ctx.tls_key_file || path == ctx.tls_cert_file)
{