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>
52 struct DirectoryInfo {
54 XrdCl::DirectoryList *fDirList;
55 XrdCl::DirectoryList::Iterator *fDirListIter;
58 DirectoryInfo(
const char *dir) : fUrl(new XrdCl::URL(dir)), fDirList(0), fDirListIter(0) {}
87 TSystem(
"-root",
"Net file Helper System")
89 using namespace XrdCl;
93 fUrl =
new URL(std::string(url));
115 using namespace XrdCl;
117 DirectoryInfo *dirInfo =
new DirectoryInfo(dir);
119 return (
void *) dirInfo;
130 using namespace XrdCl;
132 XRootDStatus st =
fFileSystem->MkDir(url.GetPath(), MkDirFlags::MakePath,
135 Error(
"MakeDirectory",
"%s", st.GetErrorMessage().c_str());
150 delete (DirectoryInfo *) dirp;
161 using namespace XrdCl;
162 DirectoryInfo *dirInfo = (DirectoryInfo *) dirp;
164 if (!dirInfo->fDirList) {
165 XRootDStatus st =
fFileSystem->DirList(dirInfo->fUrl->GetPath(),
166 DirListFlags::Locate,
169 Error(
"GetDirEntry",
"%s", st.GetErrorMessage().c_str());
172 dirInfo->fDirListIter =
new DirectoryList::Iterator(dirInfo->fDirList->Begin());
175 if (*(dirInfo->fDirListIter) != dirInfo->fDirList->End()) {
176 const char *filename = (**(dirInfo->fDirListIter))->
GetName().c_str();
177 (*(dirInfo->fDirListIter))++;
194 using namespace XrdCl;
197 XRootDStatus st =
fFileSystem->Stat(target.GetPath(), info);
202 Info(
"GetPathInfo",
"Stat error: %s", st.GetErrorMessage().c_str());
210 if (info->TestFlags(StatInfo::Offline)) {
213 std::stringstream sstr(info->GetId());
217 buf.
fDev = (
id >> 32);
218 buf.
fIno = (
id & 0x00000000FFFFFFFF);
222 buf.
fSize = info->GetSize();
223 buf.
fMtime = info->GetModTime();
225 if (info->TestFlags(StatInfo::XBitSet))
230 if (info->TestFlags(StatInfo::IsReadable)) buf.
fMode |=
kS_IRUSR;
231 if (info->TestFlags(StatInfo::IsWritable)) buf.
fMode |=
kS_IWUSR;
248 using namespace XrdCl;
255 Info(
"ConsistentWith",
"Protocol: '%s' (%s), Username: '%s' (%s), "
256 "Password: '%s' (%s), Hostname: '%s' (%s), Port: %d (%d)",
257 fUrl->GetProtocol().c_str(), url.GetProtocol().c_str(),
258 fUrl->GetUserName().c_str(), url.GetUserName().c_str(),
259 fUrl->GetPassword().c_str(), url.GetPassword().c_str(),
260 fUrl->GetHostName().c_str(), url.GetHostName().c_str(),
261 fUrl->GetPort(), url.GetPort());
264 if(
fUrl->GetProtocol() == url.GetProtocol() &&
265 fUrl->GetUserName() == url.GetUserName() &&
266 fUrl->GetPassword() == url.GetPassword() &&
267 fUrl->GetHostName() == url.GetHostName() &&
268 fUrl->GetPort() == url.GetPort())
286 using namespace XrdCl;
291 XRootDStatus st =
fFileSystem->Stat(url.GetPath(), info);
293 Error(
"Unlink",
"%s", st.GetErrorMessage().c_str());
297 if (info->TestFlags(StatInfo::IsDir))
304 Error(
"Unlink",
"%s", st.GetErrorMessage().c_str());
332 using namespace XrdCl;
333 LocationInfo *info = 0;
337 XRootDStatus st =
fFileSystem->Locate(pathUrl.GetPath(), OpenFlags::None,
340 Error(
"Locate",
"%s", st.GetErrorMessage().c_str());
346 URL locUrl(info->Begin()->GetAddress());
347 TString loc = locUrl.GetHostName();
359#if XrdVNUMBER >= 40000
361 netaddr.Set(loc.
Data());
362 const char*
name = netaddr.Name();
366 hn =
new TNamed(loc, loc);
369 char *addr[1] = {0}, *
name[1] = {0};
370 int naddr = XrdSysDNS::getAddrName(loc.
Data(), 1, addr,
name);
374 hn =
new TNamed(loc, loc);
417 using namespace XrdCl;
418 std::vector<std::string> fileList;
426 Warning(
"Stage",
"object is of unexpected type %s - ignoring",
431 fileList.push_back(std::string(URL(path.
Data()).GetPath()));
435 XRootDStatus st =
fFileSystem->Prepare(fileList, PrepareFlags::Stage,
436 (uint8_t) priority, response);
438 Error(
"Stage",
"%s", st.GetErrorMessage().c_str());
int Int_t
Signed integer 4 bytes (int).
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
bool Bool_t
Boolean (0=false, 1=true) (bool).
long long Long64_t
Portable signed long integer 8 bytes.
TSystem * ROOT_Plugin_TNetXNGSystem(const char *url, Bool_t owner)
PluginManager creation function.
#define R__LOCKGUARD(mutex)
Collection abstract base class.
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...
void Add(TObject *obj) override
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
Enables access to XRootD filesystem interface using the new client.
Bool_t ConsistentWith(const char *path, void *dirptr) override
Check consistency of this helper with the one required by 'path' or 'dirptr'.
int Unlink(const char *path) override
Unlink a file on the remote server.
XrdCl::FileSystem * fFileSystem
static TMutex fgAddrMutex
void * OpenDirectory(const char *dir) override
Open a directory.
std::set< void * > fDirPtrs
static THashList fgAddrFQDN
Int_t GetPathInfo(const char *path, FileStat_t &buf) override
Get info about a file (stat).
const char * GetDirEntry(void *dirp) override
Get a directory entry.
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.
void FreeDirectory(void *dirp) override
Free a directory.
TNetXNGSystem(Bool_t owner=kTRUE)
Constructor: Create system class without connecting to server.
virtual ~TNetXNGSystem()
Destructor.
Bool_t IsPathLocal(const char *path) override
Is this path a local path?
Int_t MakeDirectory(const char *dir) override
Create a directory.
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.
TObject()
TObject constructor.
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.
TSystem(const TSystem &)=delete
This class represents a WWW compatible URL.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
void SetHost(const char *host)