TAlienDirectory.cxx

Go to the documentation of this file.
00001 // @(#)root/alien:$Id: TAlienDirectory.cxx 24510 2008-06-24 09:49:15Z rdm $
00002 // Author: Jan Fiete Grosse-Oetringhaus   28/9/2004
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TAlienDirectory                                                      //
00015 //                                                                      //
00016 // Class which creates Directory files for the AliEn middleware         //
00017 //                                                                      //
00018 //////////////////////////////////////////////////////////////////////////
00019 
00020 #include "TAlienDirectory.h"
00021 #include "TAlien.h"
00022 #include "TGridResult.h"
00023 #include "TSystemFile.h"
00024 #include "TAlienFile.h"
00025 #include "TSystem.h"
00026 #include "TFile.h"
00027 #include "TObjString.h"
00028 
00029 
00030 ClassImp(TAlienDirectoryEntry)
00031 
00032 //______________________________________________________________________________
00033 void TAlienDirectoryEntry::Browse(TBrowser* b)
00034 {
00035    // Browse an Alien directory.
00036 
00037    if (b) {
00038       TString alienname = "alien://";
00039       alienname += fLfn;
00040       TObject *bobj;
00041       if (!(bobj = fBrowserObjects.FindObject(alienname.Data()))) {
00042          TFile *newfile = TFile::Open(alienname.Data());
00043          b->Add(newfile);
00044          fBrowserObjects.Add(new TObjString(alienname.Data()), (TObject*) newfile);
00045       }
00046    }
00047 }
00048 
00049 
00050 ClassImp(TAlienDirectory)
00051 
00052 //______________________________________________________________________________
00053 TAlienDirectory::TAlienDirectory(const char *ldn, const char *name)
00054 {
00055    // Constructor.
00056 
00057    if (!gGrid->Cd(ldn)) {
00058       MakeZombie();
00059       return;
00060    }
00061 
00062    if (!name) {
00063       SetName(gSystem->BaseName(ldn));
00064    } else {
00065       SetName(name);
00066    }
00067 
00068    SetTitle(ldn);
00069 };
00070 
00071 //______________________________________________________________________________
00072 void TAlienDirectory::Fill()
00073 {
00074    // Fill directory entry list.
00075 
00076    if (!gGrid->Cd(GetTitle())) {
00077       MakeZombie();
00078       return;
00079    }
00080 
00081    fEntries.Clear();
00082    TGridResult *dirlist = gGrid->Ls(GetTitle(), "-la");
00083    if (dirlist) {
00084       dirlist->Sort();
00085       Int_t i = 0;
00086       while (dirlist->GetFileName(i)) {
00087          if (!strcmp(".",dirlist->GetFileName(i))) {
00088             i++;
00089             continue;
00090          }
00091          if (!strcmp("..",dirlist->GetFileName(i))) {
00092             i++;
00093             continue;
00094          }
00095 
00096          if (dirlist->GetKey(i,"permissions")[0] == 'd') {
00097             fEntries.Add(new TAlienDirectory(dirlist->GetFileNamePath(i)));
00098          } else {
00099             fEntries.Add(new TAlienDirectoryEntry(dirlist->GetFileNamePath(i), dirlist->GetFileName(i)));
00100          }
00101          i++;
00102       }
00103       delete dirlist;
00104    }
00105 }
00106 
00107 //______________________________________________________________________________
00108 void TAlienDirectory::Browse(TBrowser *b)
00109 {
00110    // Browser interface to ob status.
00111 
00112    if (b) {
00113       Fill();
00114       TIter next(&fEntries);
00115       TObject *obj = 0;
00116       TObject *bobj = 0;
00117       while ((obj = next())) {
00118          if (!(bobj = fBrowserObjects.FindObject(obj->GetName()))) {
00119             b->Add(obj, obj->GetName());
00120             fBrowserObjects.Add(new TObjString(obj->GetName()), (TObject*) obj);
00121          } else {
00122             b->Add(bobj, bobj->GetName());
00123          }
00124       }
00125    }
00126 }
00127 
00128 //______________________________________________________________________________
00129 TAlienDirectory::~TAlienDirectory()
00130 {
00131    // Destructor.
00132 
00133    fEntries.Clear();
00134 }

Generated on Tue Jul 5 14:45:29 2011 for ROOT_528-00b_version by  doxygen 1.5.1