<commit_before>// @(#)root/net:$Name:  $:$Id: TXNetFileStager.cxx,v 1.3 2007/03/19 14:45:20 rdm Exp $
// Author: <NAME>, <NAME>   7/2/2007

/*************************************************************************
 * Copyright (C) 1995-2002, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TXNetFileStager                                                      //
//                                                                      //
// Interface to the 'XRD' staging capabilities.                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TError.h"
#include "TObjString.h"
#include "TUrl.h"
#include "TXNetFileStager.h"
#include "TXNetSystem.h"

//_____________________________________________________________________________
TXNetFileStager::TXNetFileStager(const char *url) : TFileStager("xrd")
{
   // Constructor. Init a TXNetSystem instance to the XRD system.

   fSystem = 0;
   if (url && strlen(url) > 0) {
      GetPrefix(url, fPrefix);
      fSystem = new TXNetSystem(fPrefix);
   }
}

//_____________________________________________________________________________
TXNetFileStager::~TXNetFileStager()
{
   // Destructor

   if (fSystem)
      delete fSystem;
   fSystem = 0;
   fPrefix = "";
}

//_____________________________________________________________________________
Bool_t TXNetFileStager::IsStaged(const char *path)
{
   // Check if the file defined by 'path' is ready to be used

   if (!IsValid()) {
      GetPrefix(path, fPrefix);
      fSystem = new TXNetSystem(path);
   }

   if (IsValid()) {
      TString p(path);
      if (!p.BeginsWith("root:"))
         p.Insert(0, fPrefix);
      return !(fSystem->AccessPathName(p, kFileExists));
   }

   // Failure
   Warning("IsStaged","TXNetSystem not initialized");
   return kFALSE;
}

//_____________________________________________________________________________
Bool_t TXNetFileStager::Stage(const char *path, Option_t *opt)
{
   // Issue a stage request for file defined by 'path'. The string 'opt'<commit_msg>From Andreas: fix in IsStaged(), return value of IsOnline() iso AccessPathName().<commit_after>// @(#)root/net:$Name:  $:$Id: TXNetFileStager.cxx,v 1.4 2007/05/03 11:52:08 rdm Exp $
// Author: <NAME>, <NAME>   7/2/2007

/*************************************************************************
 * Copyright (C) 1995-2002, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TXNetFileStager                                                      //
//                                                                      //
// Interface to the 'XRD' staging capabilities.                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TError.h"
#include "TObjString.h"
#include "TUrl.h"
#include "TXNetFileStager.h"
#include "TXNetSystem.h"

//_____________________________________________________________________________
TXNetFileStager::TXNetFileStager(const char *url) : TFileStager("xrd")
{
   // Constructor. Init a TXNetSystem instance to the XRD system.

   fSystem = 0;
   if (url && strlen(url) > 0) {
      GetPrefix(url, fPrefix);
      fSystem = new TXNetSystem(fPrefix);
   }
}

//_____________________________________________________________________________
TXNetFileStager::~TXNetFileStager()
{
   // Destructor

   if (fSystem)
      delete fSystem;
   fSystem = 0;
   fPrefix = "";
}

//_____________________________________________________________________________
Bool_t TXNetFileStager::IsStaged(const char *path)
{
   // Check if the file defined by 'path' is ready to be used.

   if (!IsValid()) {
      GetPrefix(path, fPrefix);
      fSystem = new TXNetSystem(path);
   }

   if (IsValid()) {
      TString p(path);
      if (!p.BeginsWith("root:"))
         p.Insert(0, fPrefix);
      return (fSystem->IsOnline(p));
   }

   // Failure
   Warning("IsStaged","TXNetSystem not initialized");
   return kFALSE;
}

//_____________________________________________________________________________
Bool_t TXNetFileStager::Stage(const char *path, Option_t *opt)
{
   // Issue a stage request for file defined by 'path'. The string 'opt'
{'fraction_non_alphanumeric': 0.20634027386981804, 'fraction_numerical': 0.012755580566497842, 'mean_word_length': 1.6500994035785288, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6484268', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1198, 'n_words': 294}