88#include " ROOT/RFile.hxx"
99
1010#include < ROOT/StringUtils.hxx>
11+ #include < ROOT/RLogger.hxx>
1112#include < ROOT/RError.hxx>
1213
1314#include < Byteswap.h>
@@ -30,6 +31,8 @@ ROOT::RLogChannel &ROOT::Experimental::Internal::RFileLog()
3031using ROOT::Experimental::RFile;
3132using ROOT::Experimental::Internal::RFileLog;
3233
34+ static constexpr int kDefaultCompression = ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose ;
35+
3336namespace {
3437enum class ENameCycleError {
3538 kNoError ,
@@ -224,7 +227,8 @@ std::unique_ptr<RFile> RFile::Update(std::string_view path)
224227std::unique_ptr<RFile> RFile::Recreate (std::string_view path)
225228{
226229 TDirectory::TContext ctx (nullptr ); // XXX: probably not thread safe?
227- auto tfile = std::unique_ptr<TFile>(TFile::Open (std::string (path).c_str (), " RECREATE_WITHOUT_GLOBALREGISTRATION" ));
230+ auto tfile = std::unique_ptr<TFile>(
231+ TFile::Open (std::string (path).c_str (), " RECREATE_WITHOUT_GLOBALREGISTRATION" , " " , kDefaultCompression ));
228232 EnsureFileOpenAndBinary (tfile.get (), path);
229233
230234 auto rfile = std::unique_ptr<RFile>(new RFile (std::move (tfile)));
@@ -235,6 +239,20 @@ RFile::RFile(std::unique_ptr<TFile> file) : fFile(std::move(file)) {}
235239
236240RFile::~RFile () = default ;
237241
242+ void RFile::SetCompressionSettings (int compression)
243+ {
244+ if (fFile ->IsWritable ())
245+ fFile ->SetCompressionSettings (compression);
246+ else
247+ R__LOG_WARNING (RFileLog ()) << " Tried to change compression settings on a non-writable file: this has no effect." ;
248+ }
249+
250+ void RFile::SetCompressionSettings (ROOT::RCompressionSetting::EAlgorithm::EValues algorithm, int level)
251+ {
252+ int settings = ROOT::CompressionSettings (algorithm, level);
253+ SetCompressionSettings (settings);
254+ }
255+
238256TKey *RFile::GetTKey (std::string_view path) const
239257{
240258 // In RFile, differently from TFile, when dealing with a path like "a/b/c", we always consider it to mean
0 commit comments