@@ -28,17 +28,6 @@ ROOT::RLogChannel &ROOT::Experimental::Internal::RFileLog()
2828using ROOT::Experimental::RFile;
2929using ROOT::Experimental::Internal::RFileLog;
3030
31- static void CheckExtension (std::string_view path)
32- {
33- if (ROOT::EndsWith (path, " .xml" )) {
34- throw ROOT::RException (R__FAIL (" ROOT::RFile doesn't support XML files." ));
35- }
36-
37- if (!ROOT::EndsWith (path, " .root" )) {
38- R__LOG_INFO (RFileLog ()) << " ROOT::RFile only supports ROOT files. The preferred file extension is \" .root\" " ;
39- }
40- }
41-
4231namespace {
4332enum class ENameCycleError {
4433 kNoError ,
@@ -186,39 +175,42 @@ RFile::~RFile() = default;
186175
187176std::unique_ptr<RFile> RFile::Open (std::string_view path)
188177{
189- CheckExtension (path);
190-
191178 TDirectory::TContext ctx (nullptr ); // XXX: probably not thread safe?
192179 auto tfile = std::unique_ptr<TFile>(TFile::Open (std::string (path).c_str (), " READ_WITHOUT_GLOBALREGISTRATION" ));
193180 if (!tfile || tfile->IsZombie ())
194181 throw ROOT::RException (R__FAIL (" failed to open file " + std::string (path) + " for reading" ));
195182
183+ if (tfile->IsRaw ())
184+ throw ROOT::RException (R__FAIL (" Opened file " + std::string (path) + " is not a ROOT file" ));
185+
196186 auto rfile = std::unique_ptr<RFile>(new RFile (std::move (tfile)));
197187 return rfile;
198188}
199189
200190std::unique_ptr<RFile> RFile::Update (std::string_view path)
201191{
202- CheckExtension (path);
203-
204192 TDirectory::TContext ctx (nullptr ); // XXX: probably not thread safe?
205193 auto tfile = std::unique_ptr<TFile>(TFile::Open (std::string (path).c_str (), " UPDATE_WITHOUT_GLOBALREGISTRATION" ));
206194 if (!tfile || tfile->IsZombie ())
207195 throw ROOT::RException (R__FAIL (" failed to open file " + std::string (path) + " for updating" ));
208196
197+ if (tfile->IsRaw ())
198+ throw ROOT::RException (R__FAIL (" Opened file " + std::string (path) + " is not a ROOT file" ));
199+
209200 auto rfile = std::unique_ptr<RFile>(new RFile (std::move (tfile)));
210201 return rfile;
211202}
212203
213204std::unique_ptr<RFile> RFile::Recreate (std::string_view path)
214205{
215- CheckExtension (path);
216-
217206 TDirectory::TContext ctx (nullptr ); // XXX: probably not thread safe?
218207 auto tfile = std::unique_ptr<TFile>(TFile::Open (std::string (path).c_str (), " RECREATE_WITHOUT_GLOBALREGISTRATION" ));
219208 if (!tfile || tfile->IsZombie ())
220209 throw ROOT::RException (R__FAIL (" failed to open file " + std::string (path) + " for writing" ));
221210
211+ if (tfile->IsRaw ())
212+ throw ROOT::RException (R__FAIL (" Opened file " + std::string (path) + " is not a ROOT file" ));
213+
222214 auto rfile = std::unique_ptr<RFile>(new RFile (std::move (tfile)));
223215 return rfile;
224216}
0 commit comments