File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed
Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -151,15 +151,8 @@ Result<bool> LocalFile::Mkdir() const {
151151 dir.resize (len - 1 );
152152 }
153153 }
154- size_t pos = dir.rfind (' /' );
155- if (pos == std::string::npos) {
156- return mkdir (dir.c_str (), 0755 ) == 0 ;
157- }
158- std::string parent_dir = dir.substr (0 , pos);
159- if (!parent_dir.empty () && access (parent_dir.c_str (), F_OK) != 0 ) {
160- PAIMON_RETURN_NOT_OK (MkNestDir (parent_dir));
161- }
162- return mkdir (dir.c_str (), 0755 ) == 0 ;
154+ PAIMON_ASSIGN_OR_RAISE (bool success, MkNestDir (dir));
155+ return success;
163156}
164157
165158Result<std::unique_ptr<LocalFileStatus>> LocalFile::GetFileStatus () const {
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ Status LocalFileSystem::Mkdirs(const std::string& path) const {
7676}
7777
7878Status LocalFileSystem::MkdirsInternal (const LocalFile& file) const {
79- // Important: The 'Exists()' check above must come before the 'IsDirectory ()'
79+ // Important: The 'Exists()' check above must come before the 'IsDir ()'
8080 // check to be safe when multiple parallel instances try to create the directory
8181 PAIMON_ASSIGN_OR_RAISE (bool is_exist, file.Exists ());
8282 if (is_exist) {
@@ -90,6 +90,10 @@ Status LocalFileSystem::MkdirsInternal(const LocalFile& file) const {
9090 }
9191 }
9292
93+ auto parent = file.GetParentFile ();
94+ if (!parent.IsEmpty ()) {
95+ PAIMON_RETURN_NOT_OK (MkdirsInternal (parent));
96+ }
9397 PAIMON_ASSIGN_OR_RAISE (bool success, file.Mkdir ());
9498 if (!success) {
9599 PAIMON_ASSIGN_OR_RAISE (bool is_dir, file.IsDir ());
You can’t perform that action at this time.
0 commit comments