Skip to content

Commit 4da088e

Browse files
committed
[io] TDirectoryFile: propagate returnExistingDirectory to sub-calls
1 parent fac9b1c commit 4da088e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

io/io/src/TDirectoryFile.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ TDirectory *TDirectoryFile::mkdir(const char *name, const char *title, Bool_t re
12871287
tmpdir = (TDirectoryFile*)mkdir(workname.Data(),title);
12881288
if (!tmpdir) return nullptr;
12891289
}
1290-
return tmpdir->mkdir(slash + 1);
1290+
return tmpdir->mkdir(slash + 1, "", returnExistingDirectory);
12911291
}
12921292

12931293
TDirectory::TContext ctxt(this);

io/io/test/TFileTests.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "gtest/gtest.h"
77

8+
#include <ROOT/TestSupport.hxx>
9+
810
#include "TFile.h"
911
#include "TMemFile.h"
1012
#include "TDirectory.h"
@@ -280,6 +282,21 @@ TEST(TDirectoryFile, SeekParent)
280282
EXPECT_EQ(dir11->GetSeekParent(), 239);
281283
}
282284

285+
TEST(TDirectoryFile, RecursiveMkdir)
286+
{
287+
TMemFile f("mkdirtest.root", "RECREATE");
288+
auto dir1 = f.mkdir("a/b/c");
289+
EXPECT_NE(dir1, nullptr);
290+
{
291+
ROOT::TestSupport::CheckDiagsRAII diags;
292+
diags.requiredDiag(kError, "TDirectoryFile::mkdir","An object with name c exists already");
293+
auto dir2 = f.mkdir("a/b/c", "", /* returnExisting = */ false);
294+
EXPECT_EQ(dir2, nullptr);
295+
}
296+
auto dir3 = f.mkdir("a/b/c", "", /* returnExisting = */ true);
297+
EXPECT_EQ(dir3, dir1);
298+
}
299+
283300
// https://its.cern.ch/jira/browse/ROOT-10581
284301
TEST(TFile, PersistTObjectStdArray)
285302
{

0 commit comments

Comments
 (0)