KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
SRB.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Fri Jul 17 15:10:29 2009
2 //Author: John Frankland
3 
4 #include "SRB.h"
5 #include "TList.h"
6 #include "TObjArray.h"
7 #include "TObjString.h"
8 
10 
11 
12 
14 SRB::SRB()
15  : KVDMS("SRB", "Storage Resource Broker")
16 {
17 }
18 
19 
20 
22 
24 {
25 }
26 
27 
28 
31 
33 {
34  // Call in interactive session if you want to use relative pathnames
35  buildCommand("Sinit");
36  return execCommand();
37 }
38 
39 
40 
44 
45 TString SRB::list(const Char_t* directory)
46 {
47  // returns simple listing of current directory (default) or given directory.
48  // returns empty string if directory is unknown.
49 
50  buildCommand("Sls", directory);
51  return pipeCommand();
52 }
53 
54 
55 
59 
60 TString SRB::longlist(const Char_t* directory)
61 {
62  // returns long-format listing of current directory (default) or given directory.
63  // returns empty string if directory is unknown.
64 
65  buildCommand("Sls", directory, "-l");
66  return pipeCommand();
67 }
68 
69 
70 
73 
74 Int_t SRB::cd(const Char_t* directory)
75 {
76  // change directory
77 
78  buildCommand("Scd", directory);
79  return execCommand();
80 }
81 
82 
83 
86 
88 {
89  // returns meta-infos on given file.
90 
91  buildCommand("SgetD", file, opt);
92  return pipeCommand();
93 }
94 
95 
96 
100 
101 Int_t SRB::put(const Char_t* source, const Char_t* target)
102 {
103  // put a new file into SRB space.
104  // options "-v -M" are used by default.
105 
106  TString args;
107  args.Form("%s %s", source, target);
108  buildCommand("Sput", args.Data(), "-v -M");
109  return execCommand();
110 }
111 
112 
113 
117 
118 Int_t SRB::get(const Char_t* source, const Char_t* target)
119 {
120  // copy a file from SRB space.
121  // options "-v -M" are used by default.
122 
123  TString args;
124  args.Form("%s %s", source, target);
125  buildCommand("Sget", args.Data(), "-v -M");
126  return execCommand();
127 }
128 
129 
130 
135 
137 {
138  // Delete a file
139  // WARNING: THIS WILL DELETE THE PHYSICAL FILE,
140  // not just the catalogue entry!!!
141 
142  buildCommand("Srm", path, "-f");
143  return execCommand();
144 }
145 
146 
147 
150 
151 Int_t SRB::mkdir(const Char_t* path, Option_t* opt)
152 {
153  // Create new directory in SRB space
154 
155  buildCommand("Smkdir", path, opt);
156  return execCommand();
157 }
158 
159 
160 
163 
165 {
166  // Call at end of interactive session (i.e. if you previously called Sinit())
167  buildCommand("Sexit");
168  return execCommand();
169 }
170 
171 
172 
177 
179 {
180  // extract info (name, size, modification date) from listing line
181  // such as :
182  // nief 0 Lyon 230663725 2008-12-19-15.21 run788.root.2006-10-30_08:03:15
183  TObjArray* fstats = s.Tokenize(" ");
184  f->SetName(((TObjString*)(*fstats)[5])->String().Remove(TString::kBoth, ' ').Data());
185  f->SetSize((UInt_t)((TObjString*)(*fstats)[3])->String().Remove(TString::kBoth, ' ').Atoi());
186  KVDatime mt(((TObjString*)(*fstats)[4])->String().Remove(TString::kBoth, ' ').Data(), KVDatime::kSRB);
187  f->SetModTime(mt);
188  delete fstats;
189 }
190 
191 
int Int_t
unsigned int UInt_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define f(i)
char Char_t
const char Option_t
Abstract base class for interfaces to Data Management Systems (SRB, IRODS, etc.)
Definition: KVDMS.h:59
TString pipeCommand()
Definition: KVDMS.cpp:95
Int_t execCommand()
Definition: KVDMS.cpp:79
Bool_t buildCommand(const Char_t *scmd, const Char_t *args="", Option_t *opts="")
Definition: KVDMS.cpp:48
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:32
@ kSRB
Definition: KVDatime.h:44
Interface to SRB (Storage Resource Broker) DMS client.
Definition: SRB.h:14
virtual TString longlist(const Char_t *directory="")
Definition: SRB.cpp:60
virtual ~SRB()
Definition: SRB.cpp:23
virtual Int_t exit()
Call at end of interactive session (i.e. if you previously called Sinit())
Definition: SRB.cpp:164
virtual TString info(const Char_t *file, Option_t *opt="")
returns meta-infos on given file.
Definition: SRB.cpp:87
virtual Int_t init()
Call in interactive session if you want to use relative pathnames.
Definition: SRB.cpp:32
virtual Int_t get(const Char_t *source, const Char_t *target=".")
Definition: SRB.cpp:118
virtual Int_t cd(const Char_t *directory="")
change directory
Definition: SRB.cpp:74
virtual Int_t put(const Char_t *source, const Char_t *target=".")
Definition: SRB.cpp:101
virtual TString list(const Char_t *directory="")
Definition: SRB.cpp:45
virtual Int_t forcedelete(const Char_t *path)
Definition: SRB.cpp:136
virtual void ExtractFileInfos(TString &, DMSFile_t *) const
Definition: SRB.cpp:178
virtual Int_t mkdir(const Char_t *path, Option_t *opt="")
Create new directory in SRB space.
Definition: SRB.cpp:151
const char * Data() const
void Form(const char *fmt,...)
const long double s
Definition: KVUnits.h:94
const char * String