10#include "KVDataRepository.h"
11#include "KVDataSetManager.h"
31#define CHMODE(u,g,o) ((u << 6) + (g << 3) + o)
52 gDataRepository =
this;
53 gDataSetManager =
fDSM;
83 Error(
"Init",
"Top-level directory for repository %s is not defined. Set %s.DataRepository.RootDir variable in .kvrootrc",
116 GetValue(
Form(
"%s.DataRepository.FileTransfer.type",
GetName()),
122 Error(
"Init",
"Executable for bbftp client not found. Check %s.DataRepository.FileTransfer.type",
140 GetValue(
Form(
"%s.DataRepository.FileTransfer.server",
GetName()),
169 Info(
"Print",
"configuration of repository is as follows - ");
170 cout <<
"\tname = " <<
GetName() << endl;
176 cout <<
"\tCanWrite = " <<
fCanWrite << endl;
181 cout <<
"\tXRDTunnel.port = " <<
fXRDtunPort << endl;
273 else if (tmp ==
"root")
276 else if (tmp ==
"rfio")
280 "Unknown protocol in call to SetFullPath : %s", protocol);
389 if (read_proto ==
"none") {
390 Error(
"GetFullPathToOpenFile",
"Datatype \"%s\" can not be read from the repository \"%s\"",
476 (
"%s.DataRepository.ReadProtocol.%s.%s",
GetName(),
477 dataset, datatype),
"");
483 (
"%s.DataRepository.ReadProtocol.%s",
GetName(), dataset),
490 (
"%s.DataRepository.ReadProtocol.%s",
GetName(), datatype),
507 const Char_t* destination)
553 Error(
"CopyFileToRepository",
"Problem copying file %s to repository (%d)",
582 if (strcmp(datatype,
""))
586 cout <<
"Creating new repository directory: " << path.
Data() << endl;
625 if (strcmp(datatype,
"")) {
628 if (strcmp(subdir,
"")) {
636 Error(
"KVDataRepository::GetDirectoryListing",
"Cannot open %s",
690 cout <<
"CreateNewFile : " <<
filename << endl;
805 cout <<
"Deleting file from repository: " <<
filename << endl;
808 "Are you sure you want to delete this file permanently ? (y/n)"
814 cout <<
"File not deleted" << endl;
866 while ((helper = (
TSystem*) next()))
878 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TSystem", path)) &&
879 h->LoadPlugin() == 0)
882#ifdef __WITHOUT_TNETSYSTEM_CTOR_BOOL_T
891 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TSystem", path)) &&
892 h->LoadPlugin() == 0)
893 helper = (
TSystem*)
h->ExecPlugin(0);
898 else if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TSystem", path))) {
899 if (
h->LoadPlugin() == -1)
901 helper = (
TSystem*)
h->ExecPlugin(0);
963 if (overwrite) open_option.
Prepend(
"RE");
974 int bufsize = 1024 * 1024;
976 if (filesize > 0 && filesize < 1024 * 1024) bufsize = 1024;
977 char* buf =
new char[bufsize];
980 Long64_t bytes_read, bytes_wrote, bytes_left, last_bytes_read, last_bytes_wrote;
981 bytes_read = bytes_wrote = bytes_left = last_bytes_read = last_bytes_wrote = 0;
987 while (bufsize && !ret && !from->
ReadBuffer(buf, bufsize)) {
994 if (bytes_wrote != bytes_read)
997 bytes_left = filesize - last_bytes_read;
998 if (bytes_left < bufsize) bufsize = (int)bytes_left;
1054 return (checkproto || checkdir);
1105 Error(
"PrepareXRDTunnel",
"Give host through which to tunnel : %s.DataRepository.XRDTunnel.host",
1234 if (fname ==
"")
return nullptr;
1325 base_class = plugin_class;
1329 cl = TClass::GetClass(base_class.
Data());
1332 cl = TClass::GetClass(ph->
GetClass());
1337 if (strcmp(opt,
"")) {
1347 if (ph)
Error(
"OpenDataSetFile",
"Open method for class %s is not valid", ph->
GetClass());
1348 else Error(
"OpenDataSetFile",
"Open method for class %s is not valid", base_class.
Data());
1384#ifdef __CCIN2P3_RFIO
1399 FILE* rfio_fopen(
const char* path,
const char* mode);
1400 int rfio_fclose(FILE* s);
1401 int rfio_fread(
void* buffer,
size_t size,
size_t count, FILE* stream);
1402 int rfio_fwrite(
const void* buffer,
size_t size,
size_t count, FILE* stream);
1403 int rfio_feof(FILE* stream);
1404 int rfio_stat(
const char* path,
struct stat* statbuf);
1405 int rfio_rmdir(
const char* path);
1406 int rfio_unlink(
const char* path);
1407 int rfio_chmod(
const char* path, mode_t mode);
1417Int_t KVRFIOSystem::Unlink(
const char* path)
1424 if (rfio_stat(url.GetFile(), &finfo) < 0)
1428 return rfio_rmdir(url.GetFile());
1430 return rfio_unlink(url.GetFile());
1439int KVRFIOSystem::Chmod(
const char*
file,
UInt_t mode)
1444 return rfio_chmod(url.GetFile(), mode);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char * Form(const char *fmt,...)
void AssignAndDelete(TString &target, char *tobedeleted)
Bool_t R_ISDIR(Int_t mode)
R__EXTERN TSystem * gSystem
Handles lists of available runs for different datasets and types of data.
static Bool_t FindExecutable(TString &exec, const Char_t *path="$(PATH)")
KVBase()
Default constructor.
virtual void SetType(const Char_t *str)
static Bool_t IsThisAPlugin(const TString &uri, TString &base)
virtual const Char_t * GetType() const
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Base class for managing repositories of experimental data.
virtual KVDataSetManager * GetDataSetManager() const
Return pointer to data set manager for this repository.
virtual int CopyFileToRepository(const Char_t *source, const KVDataSet *dataset, const Char_t *datatype, const Char_t *filename)
virtual int Chmod(const char *file, UInt_t mode)
virtual TObject * OpenDataSetRunFile(const KVDataSet *ds, const Char_t *type, Int_t run, Option_t *opt="")
virtual Bool_t IsRemote() const
Returns kTRUE for remote repositories, kFALSE for local repositories.
virtual void CopyFileFromRepository(const KVDataSet *dataset, const Char_t *datatype, const Char_t *filename, const Char_t *destination)
virtual const Char_t * GetReadProtocol(const Char_t *dataset, const Char_t *datatype)
static KVDataRepository * NewRepository(const Char_t *type)
virtual void Print(Option_t *opt="") const
Print info on repository.
virtual int CopyFile(const char *f, const char *t, Bool_t overwrite=kFALSE)
virtual ~KVDataRepository()
Destructor.
virtual KVUniqueNameList * GetDirectoryListing(const KVDataSet *dataset, const Char_t *datatype="", const Char_t *subdir="")
virtual Bool_t CheckFileStatus(const KVDataSet *dataset, const Char_t *datatype, const Char_t *runfile)
KVDataSetManager * fDSM
handles datasets in repository
virtual Bool_t GetFileInfo(const KVDataSet *dataset, const Char_t *datatype, const Char_t *runfile, FileStat_t &fs)
virtual Bool_t CheckSubdirExists(const Char_t *dir, const Char_t *subdir=0)
virtual void PrepareXRDTunnel()
void SetFullPath(TString &path, const Char_t *protocol)
virtual KVAvailableRunsFile * NewAvailableRunsFile(const Char_t *, const KVDataSet *)
TSeqCollection * fHelpers
List of helper classes for alternative file/directory access.
void CreateAllNeededSubdirectories(const KVDataSet *DataSet, const Char_t *DataType)
virtual KVDataSetManager * NewDataSetManager()
Create and return pointer to new data set manager.
virtual Bool_t CanWrite() const
Bool_t HelperIsConsistentWith(TSystem *helper, const char *path, void *dirptr=0)
TSystem * FindHelper(const char *path, void *dirptr=0)
virtual void CommitFile(TFile *file, const Char_t *datatype, const KVDataSet *dataset)
virtual void DeleteFile(const KVDataSet *dataset, const Char_t *datatype, const Char_t *filename, Bool_t confirm=kTRUE)
virtual TFile * CreateNewFile(const KVDataSet *dataset, const Char_t *datatype, const Char_t *filename)
KVDataRepository()
Default constructor.
virtual const Char_t * GetFullPathToTransferFile(const KVDataSet *dataset, const Char_t *datatype, const Char_t *runfile)
virtual Bool_t IsConnected()
Always returns kTRUE for local repositories.
const KVDataSet * fCommitDataSet
used by CreateNewFile and CommitFile
virtual void MakeSubdirectory(const KVDataSet *dataset, const Char_t *datatype="")
virtual const Char_t * GetFullPathToOpenFile(const KVDataSet *dataset, const Char_t *datatype, const Char_t *runfile)
TObject * OpenDataSetFile(const KVDataSet *ds, const Char_t *type, const TString &fname, Option_t *opt="")
Manage all datasets contained in a given data repository.
virtual Bool_t Init(KVDataRepository *=0)
Manage an experimental dataset corresponding to a given experiment or campaign.
virtual const Char_t * GetDataPathSubdir() const
Returns name of top-level directory in data repository used to store data files for this dataset.
const Char_t * GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
TString GetFullPathToRunfile(const Char_t *type, Int_t run) const
const Char_t * GetDataTypeSubdir(const Char_t *type) const
virtual void SetOwner(Bool_t enable=kTRUE)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Optimised list in which named objects can only be placed once.
virtual void Add(TObject *obj)
void Delete(Option_t *option="") override=0
virtual const char * GetValue(const char *name, const char *dflt) const
virtual Long64_t GetSize() const
virtual Long64_t GetBytesRead() const
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
virtual Long64_t GetBytesWritten() const
virtual Bool_t ReadBuffer(char *buf, Int_t len)
const char * GetName() const override
const TString & GetString() const
virtual void Warning(const char *method, const char *msgfmt,...) const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * GetClass() const
Longptr_t ExecPlugin(int nargs)
void Add(TObject *obj) override
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(char c, Ssiz_t rep=1)
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual void * GetDirPtr() const
virtual int Chmod(const char *file, UInt_t mode)
virtual void FreeDirectory(void *dirp)
virtual void * OpenDirectory(const char *name)
virtual char * ConcatFileName(const char *dir, const char *name)
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
virtual int GetPathInfo(const char *path, FileStat_t &buf)
virtual UserGroup_t * GetUserInfo(const char *user=nullptr)
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
virtual const char * GetDirEntry(void *dirp)
virtual char * ExpandPathName(const char *path)
virtual int Unlink(const char *name)
const char * GetUrl(Bool_t withDeflt=kFALSE) const
void SetOptions(const char *opt)
const char * GetProtocol() const