Seaven commented on a change in pull request #2089: Change refactor and
reorganize the file utils
URL: https://github.com/apache/incubator-doris/pull/2089#discussion_r342930596
##########
File path: be/src/util/file_utils.cpp
##########
@@ -33,36 +33,64 @@
#include <openssl/md5.h>
+#include "gutil/strings/substitute.h"
+
#include "env/env.h"
#include "olap/file_helper.h"
#include "util/defer_op.h"
namespace doris {
-Status FileUtils::create_dir(const std::string& dir_path) {
- try {
- if (boost::filesystem::exists(dir_path.c_str())) {
- // No need to create one
- if (!boost::filesystem::is_directory(dir_path.c_str())) {
- std::stringstream ss;
- ss << "Path(" << dir_path << ") already exists, but not a
directory.";
- return Status::InternalError(ss.str());
+using strings::Substitute;
+
+Status FileUtils::create_dir(const std::string& path, Env* env) {
+ if (path.empty()) {
+ return Status::InvalidArgument(Substitute("Unknown primitive
type($0)", path));
+ }
+
+ boost::filesystem::path p(path);
+
+ string partial_path;
+ for (boost::filesystem::path::iterator it = p.begin(); it != p.end();
++it) {
+ partial_path = partial_path.empty() ? it->string() : partial_path +
"/" + it->string();
+ bool is_dir = false;
+
+ Status s = env->is_directory(partial_path, &is_dir);
Review comment:
We can't return here because the path maybe isn't exists.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]