KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
IRODS.cpp
Go to the documentation of this file.
1 //Created by KVClassFactory on Thu Oct 18 10:38:52 2012
2 //Author: John Frankland
3 
4 #include "IRODS.h"
5 #include "TSystem.h"
6 #include "TList.h"
7 #include "TObjArray.h"
8 #include "TObjString.h"
9 #include "KVConfig.h"
10 
12 
13 
14 
17  : KVDMS("IRODS", "Integrated Rule-Oriented Data System")
18 {
19 }
20 
21 
22 
24 
26 {
27 }
28 
29 
30 
33 
35 {
36  // Call in interactive session if you want to use relative pathnames
37  buildCommand("iinit");
38  return execCommand();
39 }
40 
41 
42 
46 
47 TString IRODS::list(const Char_t* directory)
48 {
49  // returns simple listing of current directory (default) or given directory.
50  // returns empty string if directory is unknown.
51 
52  buildCommand("ils", directory);
53  return pipeCommand();
54 }
55 
56 
57 
61 
62 TString IRODS::longlist(const Char_t* directory)
63 {
64  // returns long-format listing of current directory (default) or given directory.
65  // returns empty string if directory is unknown.
66  buildCommand("ils", directory, "-l");
67  return pipeCommand();
68 }
69 
70 
71 
74 
75 Int_t IRODS::cd(const Char_t* directory)
76 {
77  // change directory
78 
79  buildCommand("icd", directory);
80  return execCommand();
81 }
82 
83 
84 
87 
89 {
90  // returns meta-infos on given file.
91 
92  buildCommand("imeta", file, opt);
93  return pipeCommand();
94 }
95 
96 
97 
100 
101 Int_t IRODS::put(const Char_t* source, const Char_t* target)
102 {
103  // put a new file into IRODS space.
104 
105  TString args;
106  args.Form("%s %s", source, target);
107  buildCommand("iput", args.Data(), "-KP");
108  return execCommand();
109 }
110 
111 
112 
115 
116 Int_t IRODS::get(const Char_t* source, const Char_t* target)
117 {
118  // copy a file from IRODS space.
119 
120  TString args;
121  args.Form("-P %s %s", source, target);
122  buildCommand("iget", args.Data());
123  return execCommand();
124 }
125 
126 
127 
132 
134 {
135  // Delete a file.
136  // WARNING: THIS WILL DELETE THE PHYSICAL FILE,
137  // not just the catalogue entry!!!
138 
139  buildCommand("irm", path, "-f");
140  return execCommand();
141 }
142 
143 
144 
148 
150 {
151  // Change access permissions for file/directory
152 
153  //buildCommand("ichmod",path, Form("%ud",mode));
154  return 0;//execCommand();
155 }
156 
157 
158 
161 
162 Int_t IRODS::mkdir(const Char_t* path, Option_t* opt)
163 {
164  // Create new directory in IRODS space
165 
166  buildCommand("imkdir", path, opt);
167  return execCommand();
168 }
169 
170 
171 
174 
176 {
177  // Call at end of interactive session (i.e. if you previously called iinit())
178  buildCommand("iexit");
179  return execCommand();
180 }
181 
182 
183 
192 
194 {
195  // extract info (name, size, modification date) from listing line
196  // such as :
197  // indramgr 0 diskcache2 208207872 2009-10-06.16:56 & run_0002.dat.15-Feb-07.18:00:58
198  // indramgr 1 HPSS2 208207872 2009-10-06.16:56 & run_0002.dat.15-Feb-07.18:00:58
199  // indramgr 0 diskcache2 208224256 2009-10-06.16:56 & run_0003.dat.15-Feb-07.20:21:50
200  // indramgr 1 HPSS2 208224256 2009-10-06.16:56 & run_0003.dat.15-Feb-07.20:21:50
201  //
202 
203  TObjArray* fstats = s.Tokenize(" ");
204  f->SetName(((TObjString*)(*fstats)[fstats->GetEntries() - 1])->String().Remove(TString::kBoth, ' ').Data());
205  f->SetSize((UInt_t)((TObjString*)(*fstats)[3])->String().Remove(TString::kBoth, ' ').Atoi());
206  KVDatime mt(((TObjString*)(*fstats)[4])->String().Remove(TString::kBoth, ' ').Data(), KVDatime::kIRODS);
207  f->SetModTime(mt);
208  delete fstats;
209 }
210 
211 
int Int_t
unsigned int UInt_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
#define f(i)
char Char_t
const char Option_t
Interface to IRODS (Integrated Rule-Oriented Data System) DMS client.
Definition: IRODS.h:14
virtual TString longlist(const Char_t *directory="")
Definition: IRODS.cpp:62
virtual void ExtractFileInfos(TString &, DMSFile_t *) const
Definition: IRODS.cpp:193
virtual Int_t get(const Char_t *source, const Char_t *target=".")
copy a file from IRODS space.
Definition: IRODS.cpp:116
virtual Int_t put(const Char_t *source, const Char_t *target=".")
put a new file into IRODS space.
Definition: IRODS.cpp:101
virtual Int_t mkdir(const Char_t *path, Option_t *opt="")
Create new directory in IRODS space.
Definition: IRODS.cpp:162
virtual Int_t chmod(const Char_t *path, UInt_t mode)
Definition: IRODS.cpp:149
virtual Int_t forcedelete(const Char_t *path)
Definition: IRODS.cpp:133
virtual Int_t cd(const Char_t *directory="")
change directory
Definition: IRODS.cpp:75
virtual Int_t exit()
Call at end of interactive session (i.e. if you previously called iinit())
Definition: IRODS.cpp:175
virtual TString list(const Char_t *directory="")
Definition: IRODS.cpp:47
virtual ~IRODS()
Definition: IRODS.cpp:25
virtual TString info(const Char_t *file, Option_t *opt="")
returns meta-infos on given file.
Definition: IRODS.cpp:88
virtual Int_t init()
Call in interactive session if you want to use relative pathnames.
Definition: IRODS.cpp:34
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
@ kIRODS
Definition: KVDatime.h:45
Int_t GetEntries() const
const char * Data() const
void Form(const char *fmt,...)
const long double s
Definition: KVUnits.h:94
const char * String