27 #include <XrdCl/XrdClFileSystem.hh>
28 #include <XrdCl/XrdClXRootDResponses.hh>
29 #include <XrdSys/XrdSysDNS.hh>
38 struct DirectoryInfo {
40 XrdCl::DirectoryList *fDirList;
41 XrdCl::DirectoryList::Iterator *fDirListIter;
44 DirectoryInfo(
const char *
dir) : fUrl(new XrdCl::URL(dir)), fDirList(0), fDirListIter(0) {}
59 TSystem(
"-root",
"Net file Helper System"), fUrl(0), fFileSystem(0)
73 TSystem(
"-root",
"Net file Helper System")
75 using namespace XrdCl;
79 fUrl =
new URL(std::string(url));
101 using namespace XrdCl;
103 DirectoryInfo *dirInfo =
new DirectoryInfo(dir);
105 return (
void *) dirInfo;
116 using namespace XrdCl;
118 XRootDStatus st =
fFileSystem->MkDir(url.GetPath(), MkDirFlags::MakePath,
121 Error(
"MakeDirectory",
"%s", st.GetErrorMessage().c_str());
136 delete (DirectoryInfo *) dirp;
147 using namespace XrdCl;
148 DirectoryInfo *dirInfo = (DirectoryInfo *) dirp;
150 if (!dirInfo->fDirList) {
151 XRootDStatus st =
fFileSystem->DirList(dirInfo->fUrl->GetPath(),
152 DirListFlags::Locate,
155 Error(
"GetDirEntry",
"%s", st.GetErrorMessage().c_str());
158 dirInfo->fDirListIter =
new DirectoryList::Iterator(dirInfo->fDirList->Begin());
161 if (*(dirInfo->fDirListIter) != dirInfo->fDirList->End()) {
162 const char *
filename = (**(dirInfo->fDirListIter))->GetName().c_str();
163 (*(dirInfo->fDirListIter))++;
180 using namespace XrdCl;
183 XRootDStatus st =
fFileSystem->Stat(target.GetPath(), info);
188 Info(
"GetPathInfo",
"Stat error: %s", st.GetErrorMessage().c_str());
196 if (info->TestFlags(StatInfo::Offline)) {
199 std::stringstream sstr(info->GetId());
203 buf.
fDev = (
id >> 32);
204 buf.
fIno = (
id & 0x00000000FFFFFFFF);
208 buf.
fSize = info->GetSize();
209 buf.
fMtime = info->GetModTime();
211 if (info->TestFlags(StatInfo::XBitSet))
234 using namespace XrdCl;
241 Info(
"ConsistentWith",
"Protocol: '%s' (%s), Username: '%s' (%s), "
242 "Password: '%s' (%s), Hostname: '%s' (%s), Port: %d (%d)",
243 fUrl->GetProtocol().c_str(), url.GetProtocol().c_str(),
244 fUrl->GetUserName().c_str(), url.GetUserName().c_str(),
245 fUrl->GetPassword().c_str(), url.GetPassword().c_str(),
246 fUrl->GetHostName().c_str(), url.GetHostName().c_str(),
247 fUrl->GetPort(), url.GetPort());
250 if(
fUrl->GetProtocol() == url.GetProtocol() &&
251 fUrl->GetUserName() == url.GetUserName() &&
252 fUrl->GetPassword() == url.GetPassword() &&
253 fUrl->GetHostName() == url.GetHostName() &&
254 fUrl->GetPort() == url.GetPort())
272 using namespace XrdCl;
277 XRootDStatus st =
fFileSystem->Stat(url.GetPath(), info);
279 Error(
"Unlink",
"%s", st.GetErrorMessage().c_str());
284 if (info->TestFlags(StatInfo::IsDir))
291 Error(
"Unlink",
"%s", st.GetErrorMessage().c_str());
319 using namespace XrdCl;
320 LocationInfo *info = 0;
327 Error(
"Locate",
"%s", st.GetErrorMessage().c_str());
333 URL locUrl(info->Begin()->GetAddress());
334 TString loc = locUrl.GetHostName();
346 char *addr[1] = {0}, *
name[1] = {0};
347 int naddr = XrdSysDNS::getAddrName(loc.Data(), 1, addr,
name);
351 hn =
new TNamed(loc, loc);
357 Info(
"Locate",
"caching host name: %s", hn->GetTitle());
393 using namespace XrdCl;
394 std::vector<std::string> fileList;
402 Warning(
"Stage",
"object is of unexpected type %s - ignoring",
403 object->ClassName());
407 fileList.push_back(std::string(URL(path.
Data()).GetPath()));
411 XRootDStatus st =
fFileSystem->Prepare(fileList, PrepareFlags::Stage,
412 (uint8_t) priority, response);
414 Error(
"Stage",
"%s", st.GetErrorMessage().c_str());
std::set< void * > fDirPtrs
virtual Int_t MakeDirectory(const char *dir)
Create a directory.
static TString GetPathName(TObject *o)
Return the path name contained in object 'o' allowing for TUrl, TObjString or TFileInfo.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
virtual Bool_t IsPathLocal(const char *path)
Is this path a local path?
TObject * FindObject(const char *name) const
Find object using its name.
This class represents a WWW compatible URL.
virtual void SetName(const char *name)
Change (i.e.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
virtual Int_t Stage(const char *path, UChar_t priority)
Issue a stage request for a single file.
static const char * filename()
TNetXNGSystem(Bool_t owner=kTRUE)
Constructor: Create system class without connecting to server.
virtual Bool_t ConsistentWith(const char *path, void *dirptr)
Check consistency of this helper with the one required by 'path' or 'dirptr'.
const char * Data() const
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
The TNamed class is the base class for all named ROOT classes.
if(pyself &&pyself!=Py_None)
static TMutex fgAddrMutex
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual int Unlink(const char *path)
Unlink a file on the remote server.
Collection abstract base class.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual ~TNetXNGSystem()
Destructor.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
void SetHost(const char *host)
virtual Int_t GetSize() const
virtual Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file (stat)
#define R__LOCKGUARD(mutex)
Mother of all ROOT objects.
virtual void Add(TObject *obj)
static THashList fgAddrFQDN
virtual void * OpenDirectory(const char *dir)
Open a directory.
Abstract base class defining a generic interface to the underlying Operating System.
XrdCl::FileSystem * fFileSystem
virtual Int_t Locate(const char *path, TString &endurl)
Get the endpoint URL of a file.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.