28#include <XrdCl/XrdClFileSystem.hh>
29#include <XrdCl/XrdClXRootDResponses.hh>
30#include <XrdVersion.hh>
31#if XrdVNUMBER >= 40000
32#include <XrdNet/XrdNetAddr.hh>
34#include <XrdSys/XrdSysDNS.hh>
53 struct DirectoryInfo {
55 XrdCl::DirectoryList *fDirList;
56 XrdCl::DirectoryList::Iterator *fDirListIter;
59 DirectoryInfo(
const char *dir) : fUrl(new
XrdCl::URL(dir)), fDirList(0), fDirListIter(0) {}
74 TSystem(
"-root",
"Net file Helper System"), fUrl(0), fFileSystem(0)
88 TSystem(
"-root",
"Net file Helper System")
90 using namespace XrdCl;
94 fUrl =
new URL(std::string(url));
116 using namespace XrdCl;
118 DirectoryInfo *dirInfo =
new DirectoryInfo(dir);
120 return (
void *) dirInfo;
131 using namespace XrdCl;
133 XRootDStatus st =
fFileSystem->MkDir(url.GetPath(), MkDirFlags::MakePath,
136 Error(
"MakeDirectory",
"%s", st.GetErrorMessage().c_str());
151 delete (DirectoryInfo *) dirp;
162 using namespace XrdCl;
163 DirectoryInfo *dirInfo = (DirectoryInfo *) dirp;
165 if (!dirInfo->fDirList) {
166 XRootDStatus st =
fFileSystem->DirList(dirInfo->fUrl->GetPath(),
167 DirListFlags::Locate,
170 Error(
"GetDirEntry",
"%s", st.GetErrorMessage().c_str());
173 dirInfo->fDirListIter =
new DirectoryList::Iterator(dirInfo->fDirList->Begin());
176 if (*(dirInfo->fDirListIter) != dirInfo->fDirList->End()) {
177 const char *filename = (**(dirInfo->fDirListIter))->GetName().c_str();
178 (*(dirInfo->fDirListIter))++;
195 using namespace XrdCl;
198 XRootDStatus st =
fFileSystem->Stat(target.GetPath(), info);
203 Info(
"GetPathInfo",
"Stat error: %s", st.GetErrorMessage().c_str());
211 if (info->TestFlags(StatInfo::Offline)) {
214 std::stringstream sstr(info->GetId());
218 buf.
fDev = (
id >> 32);
219 buf.
fIno = (
id & 0x00000000FFFFFFFF);
223 buf.
fSize = info->GetSize();
224 buf.
fMtime = info->GetModTime();
226 if (info->TestFlags(StatInfo::XBitSet))
231 if (info->TestFlags(StatInfo::IsReadable)) buf.
fMode |=
kS_IRUSR;
232 if (info->TestFlags(StatInfo::IsWritable)) buf.
fMode |=
kS_IWUSR;
249 using namespace XrdCl;
256 Info(
"ConsistentWith",
"Protocol: '%s' (%s), Username: '%s' (%s), "
257 "Password: '%s' (%s), Hostname: '%s' (%s), Port: %d (%d)",
258 fUrl->GetProtocol().c_str(), url.GetProtocol().c_str(),
259 fUrl->GetUserName().c_str(), url.GetUserName().c_str(),
260 fUrl->GetPassword().c_str(), url.GetPassword().c_str(),
261 fUrl->GetHostName().c_str(), url.GetHostName().c_str(),
262 fUrl->GetPort(), url.GetPort());
265 if(
fUrl->GetProtocol() == url.GetProtocol() &&
266 fUrl->GetUserName() == url.GetUserName() &&
267 fUrl->GetPassword() == url.GetPassword() &&
268 fUrl->GetHostName() == url.GetHostName() &&
269 fUrl->GetPort() == url.GetPort())
287 using namespace XrdCl;
292 XRootDStatus st =
fFileSystem->Stat(url.GetPath(), info);
294 Error(
"Unlink",
"%s", st.GetErrorMessage().c_str());
298 if (info->TestFlags(StatInfo::IsDir))
305 Error(
"Unlink",
"%s", st.GetErrorMessage().c_str());
333 using namespace XrdCl;
334 LocationInfo *info = 0;
338 XRootDStatus st =
fFileSystem->Locate(pathUrl.GetPath(), OpenFlags::None,
341 Error(
"Locate",
"%s", st.GetErrorMessage().c_str());
347 URL locUrl(info->Begin()->GetAddress());
348 TString loc = locUrl.GetHostName();
360#if XrdVNUMBER >= 40000
362 netaddr.Set(loc.
Data());
363 const char*
name = netaddr.Name();
367 hn =
new TNamed(loc, loc);
370 char *addr[1] = {0}, *
name[1] = {0};
371 int naddr = XrdSysDNS::getAddrName(loc.
Data(), 1, addr,
name);
375 hn =
new TNamed(loc, loc);
418 using namespace XrdCl;
419 std::vector<std::string> fileList;
427 Warning(
"Stage",
"object is of unexpected type %s - ignoring",
432 fileList.push_back(std::string(URL(path.
Data()).GetPath()));
436 XRootDStatus st =
fFileSystem->Prepare(fileList, PrepareFlags::Stage,
437 (uint8_t) priority, response);
439 Error(
"Stage",
"%s", st.GetErrorMessage().c_str());
TSystem * ROOT_Plugin_TNetXNGSystem(const char *url, Bool_t owner)
PluginManager creation function.
#define R__LOCKGUARD(mutex)
Collection abstract base class.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
static TString GetPathName(TObject *o)
Return the path name contained in object 'o' allowing for TUrl, TObjString or TFileInfo.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
TObject * FindObject(const char *name) const
Find object using its name.
virtual void Add(TObject *obj)
The TNamed class is the base class for all named ROOT classes.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
XrdCl::FileSystem * fFileSystem
static TMutex fgAddrMutex
virtual Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file (stat)
std::set< void * > fDirPtrs
virtual Bool_t IsPathLocal(const char *path)
Is this path a local path?
static THashList fgAddrFQDN
virtual int Unlink(const char *path)
Unlink a file on the remote server.
virtual Int_t Stage(const char *path, UChar_t priority)
Issue a stage request for a single file.
virtual Int_t Locate(const char *path, TString &endurl)
Get the endpoint URL of a file.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual Int_t MakeDirectory(const char *dir)
Create a directory.
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'.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry.
virtual ~TNetXNGSystem()
Destructor.
virtual void * OpenDirectory(const char *dir)
Open a directory.
Mother of all ROOT objects.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
const char * Data() const
Abstract base class defining a generic interface to the underlying Operating System.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
This class represents a WWW compatible URL.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
void SetHost(const char *host)