Logo ROOT  
Reference Guide
TAlienDirectory.cxx
Go to the documentation of this file.
1// @(#)root/alien:$Id$
2// Author: Jan Fiete Grosse-Oetringhaus 28/9/2004
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//////////////////////////////////////////////////////////////////////////
13// //
14// TAlienDirectory //
15// //
16// Class which creates Directory files for the AliEn middleware //
17// //
18//////////////////////////////////////////////////////////////////////////
19
20#include "TAlienDirectory.h"
21#include "TAlien.h"
22#include "TGridResult.h"
23#include "TSystemFile.h"
24#include "TAlienFile.h"
25#include "TSystem.h"
26#include "TFile.h"
27#include "TObjString.h"
28
29
31
32////////////////////////////////////////////////////////////////////////////////
33/// Browse an Alien directory.
34
36{
37 if (b) {
38 TString alienname = "alien://";
39 alienname += fLfn;
40 if (!fBrowserObjects.FindObject(alienname)) {
41 TFile *newfile = TFile::Open(alienname.Data());
42 b->Add(newfile);
43 fBrowserObjects.Add(new TObjString(alienname.Data()), (TObject*) newfile);
44 }
45 }
46}
47
48
50
51////////////////////////////////////////////////////////////////////////////////
52/// Constructor.
53
54TAlienDirectory::TAlienDirectory(const char *ldn, const char *name)
55{
56 if (!gGrid->Cd(ldn)) {
57 MakeZombie();
58 return;
59 }
60
61 if (!name) {
63 } else {
65 }
66
67 SetTitle(ldn);
68};
69
70////////////////////////////////////////////////////////////////////////////////
71/// Fill directory entry list.
72
74{
75 if (!gGrid->Cd(GetTitle())) {
76 MakeZombie();
77 return;
78 }
79
81 TGridResult *dirlist = gGrid->Ls(GetTitle(), "-la");
82 if (dirlist) {
83 dirlist->Sort();
84 Int_t i = 0;
85 while (dirlist->GetFileName(i)) {
86 if (!strcmp(".",dirlist->GetFileName(i))) {
87 i++;
88 continue;
89 }
90 if (!strcmp("..",dirlist->GetFileName(i))) {
91 i++;
92 continue;
93 }
94
95 if (dirlist->GetKey(i,"permissions")[0] == 'd') {
97 } else {
98 fEntries.Add(new TAlienDirectoryEntry(dirlist->GetFileNamePath(i), dirlist->GetFileName(i)));
99 }
100 i++;
101 }
102 delete dirlist;
103 }
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// Browser interface to ob status.
108
110{
111 if (b) {
112 Fill();
113 TIter next(&fEntries);
114 TObject *obj = 0;
115 TObject *bobj = 0;
116 while ((obj = next())) {
117 if (!(bobj = fBrowserObjects.FindObject(obj->GetName()))) {
118 b->Add(obj, obj->GetName());
119 fBrowserObjects.Add(new TObjString(obj->GetName()), (TObject*) obj);
120 } else {
121 b->Add(bobj, bobj->GetName());
122 }
123 }
124 }
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// Destructor.
129
131{
132 fEntries.Clear();
133}
#define b(i)
Definition: RSha256.hxx:100
#define ClassImp(name)
Definition: Rtypes.h:364
char name[80]
Definition: TGX11.cxx:110
R__EXTERN TGrid * gGrid
Definition: TGrid.h:128
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
void Browse(TBrowser *b)
Browse an Alien directory.
void Fill()
Fill directory entry list.
TAlienDirectory(const char *ldn, const char *name=0)
Constructor.
virtual ~TAlienDirectory()
Destructor.
void Browse(TBrowser *b)
Browser interface to ob status.
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:4015
virtual const char * GetFileNamePath(UInt_t) const
Definition: TGridResult.h:39
virtual const char * GetKey(UInt_t, const char *) const
Definition: TGridResult.h:45
virtual const char * GetFileName(UInt_t) const
Definition: TGridResult.h:37
virtual TGridResult * Ls(const char *="", Option_t *="", Bool_t=kFALSE)
Definition: TGrid.h:84
virtual Bool_t Cd(const char *="", Bool_t=kFALSE)
Definition: TGrid.h:90
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Definition: TList.cxx:402
virtual void Sort(Bool_t order=kSortAscending)
Sort linked list.
Definition: TList.cxx:937
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
Definition: TMap.cxx:54
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
Definition: TMap.cxx:215
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
Collectable string class.
Definition: TObjString.h:28
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
void MakeZombie()
Definition: TObject.h:49
Basic string class.
Definition: TString.h:136
const char * Data() const
Definition: TString.h:369
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:935