mkdir and rmdir basic implementation
This commit is contained in:
19
ml_io.cpp
19
ml_io.cpp
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "ml_io.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -65,12 +66,22 @@ bool is_path_dir(const std::string &path) {
|
||||
return (bool) S_ISDIR(buf.st_mode);
|
||||
}
|
||||
|
||||
int mk_path_dir(const std::string &path) {
|
||||
return ::mkdir(path.c_str(), 0755);
|
||||
bool mk_path_dir(const std::string &path) {
|
||||
auto r = ::mkdir(path.c_str(), 0755);
|
||||
if (r == -1) {
|
||||
std::string err_msg = std::strerror(errno);
|
||||
std::cerr << "mkdir failed: " << std::strerror(errno) << std::endl;
|
||||
}
|
||||
return r == 0;
|
||||
}
|
||||
|
||||
int rm_path_dir(const std::string &path) {
|
||||
return ::rmdir(path.c_str());
|
||||
bool rm_path_dir(const std::string &path) {
|
||||
auto r = ::rmdir(path.c_str());
|
||||
if (r == -1) {
|
||||
std::string err_msg = std::strerror(errno);
|
||||
std::cerr << "rmdir failed: " << std::strerror(errno) << std::endl;
|
||||
}
|
||||
return r == 0;
|
||||
}
|
||||
|
||||
MlValue exec_system_cmd(const std::string &cmd) {
|
||||
|
||||
Reference in New Issue
Block a user