28 #include <XrdCl/XrdClFileSystem.hh>
29 #include <XrdCl/XrdClXRootDResponses.hh>
30 #include <XrdSys/XrdSysDNS.hh>
48 struct DirectoryInfo {
50 XrdCl::DirectoryList *fDirList;
51 XrdCl::DirectoryList::Iterator *fDirListIter;
54 DirectoryInfo(
const char *dir) : fUrl(new
XrdCl::URL(dir)), fDirList(0), fDirListIter(0) {}
69 TSystem(
"-root",
"Net file Helper System"), fUrl(0), fFileSystem(0)
83 TSystem(
"-root",
"Net file Helper System")
85 using namespace XrdCl;
89 fUrl =
new URL(std::string(url));
111 using namespace XrdCl;
113 DirectoryInfo *dirInfo =
new DirectoryInfo(dir);
115 return (
void *) dirInfo;
126 using namespace XrdCl;
128 XRootDStatus st =
fFileSystem->MkDir(url.GetPath(), MkDirFlags::MakePath,
131 Error(
"MakeDirectory",
"%s", st.GetErrorMessage().c_str());
146 delete (DirectoryInfo *) dirp;
157 using namespace XrdCl;
158 DirectoryInfo *dirInfo = (DirectoryInfo *) dirp;
160 if (!dirInfo->fDirList) {
161 XRootDStatus st =
fFileSystem->DirList(dirInfo->fUrl->GetPath(),
162 DirListFlags::Locate,
165 Error(
"GetDirEntry",
"%s", st.GetErrorMessage().c_str());
168 dirInfo->fDirListIter =
new DirectoryList::Iterator(dirInfo->fDirList->Begin());
171 if (*(dirInfo->fDirListIter) != dirInfo->fDirList->End()) {
172 const char *
filename = (**(dirInfo->fDirListIter))->GetName().c_str();
173 (*(dirInfo->fDirListIter))++;
190 using namespace XrdCl;
193 XRootDStatus st =
fFileSystem->Stat(target.GetPath(), info);
198 Info(
"GetPathInfo",
"Stat error: %s", st.GetErrorMessage().c_str());
206 if (info->TestFlags(StatInfo::Offline)) {
209 std::stringstream sstr(info->GetId());
213 buf.
fDev = (
id >> 32);
214 buf.
fIno = (
id & 0x00000000FFFFFFFF);
218 buf.
fSize = info->GetSize();
219 buf.
fMtime = info->GetModTime();
221 if (info->TestFlags(StatInfo::XBitSet))
244 using namespace XrdCl;
251 Info(
"ConsistentWith",
"Protocol: '%s' (%s), Username: '%s' (%s), "
252 "Password: '%s' (%s), Hostname: '%s' (%s), Port: %d (%d)",
253 fUrl->GetProtocol().c_str(), url.GetProtocol().c_str(),
254 fUrl->GetUserName().c_str(), url.GetUserName().c_str(),
255 fUrl->GetPassword().c_str(), url.GetPassword().c_str(),
256 fUrl->GetHostName().c_str(), url.GetHostName().c_str(),
257 fUrl->GetPort(), url.GetPort());
260 if(
fUrl->GetProtocol() == url.GetProtocol() &&
261 fUrl->GetUserName() == url.GetUserName() &&
262 fUrl->GetPassword() == url.GetPassword() &&
263 fUrl->GetHostName() == url.GetHostName() &&
264 fUrl->GetPort() == url.GetPort())
282 using namespace XrdCl;
287 XRootDStatus st =
fFileSystem->Stat(url.GetPath(), info);
289 Error(
"Unlink",
"%s", st.GetErrorMessage().c_str());
294 if (info->TestFlags(StatInfo::IsDir))
301 Error(
"Unlink",
"%s", st.GetErrorMessage().c_str());
329 using namespace XrdCl;
330 LocationInfo *info = 0;
337 Error(
"Locate",
"%s", st.GetErrorMessage().c_str());
343 URL locUrl(info->Begin()->GetAddress());
344 TString loc = locUrl.GetHostName();
356 char *addr[1] = {0}, *
name[1] = {0};
357 int naddr = XrdSysDNS::getAddrName(loc.Data(), 1, addr,
name);
361 hn =
new TNamed(loc, loc);
403 using namespace XrdCl;
404 std::vector<std::string> fileList;
412 Warning(
"Stage",
"object is of unexpected type %s - ignoring",
417 fileList.push_back(std::string(URL(path.
Data()).GetPath()));
421 XRootDStatus st =
fFileSystem->Prepare(fileList, PrepareFlags::Stage,
422 (uint8_t) priority, response);
424 Error(
"Stage",
"%s", st.GetErrorMessage().c_str());
virtual const char * GetTitle() const
Returns title of object.
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
Vc_ALWAYS_INLINE void free(T *p)
Frees memory that was allocated with Vc::malloc.
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.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Collection abstract base class.
TSystem * ROOT_Plugin_TNetXNGSystem(const char *url, Bool_t owner)
PluginManager creation function.
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.