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());
293 if (info->TestFlags(StatInfo::IsDir))
300 Error(
"Unlink",
"%s", st.GetErrorMessage().c_str());
328 using namespace XrdCl;
329 LocationInfo *info = 0;
336 Error(
"Locate",
"%s", st.GetErrorMessage().c_str());
342 URL locUrl(info->Begin()->GetAddress());
343 TString loc = locUrl.GetHostName();
355 char *addr[1] = {0}, *
name[1] = {0};
356 int naddr = XrdSysDNS::getAddrName(loc.Data(), 1, addr,
name);
360 hn =
new TNamed(loc, loc);
371 res.SetPort(locUrl.GetPort());
372 endurl = res.GetUrl();
402 using namespace XrdCl;
403 std::vector<std::string> fileList;
411 Warning(
"Stage",
"object is of unexpected type %s - ignoring",
416 fileList.push_back(std::string(URL(path.Data()).GetPath()));
420 XRootDStatus st =
fFileSystem->Prepare(fileList, PrepareFlags::Stage,
421 (uint8_t) priority, response);
423 Error(
"Stage",
"%s", st.GetErrorMessage().c_str());
std::set< void * > fDirPtrs
virtual Int_t MakeDirectory(const char *dir)
Create a directory.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
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?
This class represents a WWW compatible URL.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual Int_t Stage(const char *path, UChar_t priority)
Issue a stage request for a single file.
TNetXNGSystem(Bool_t owner=kTRUE)
Constructor: Create system class without connecting to server.
TObject * FindObject(const char *name) const
Find object using its name.
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 * ClassName() const
Returns name of class to which the object belongs.
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.
static TMutex fgAddrMutex
virtual int Unlink(const char *path)
Unlink a file on the remote server.
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 void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual ~TNetXNGSystem()
Destructor.
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.
virtual Int_t GetSize() const
Abstract base class defining a generic interface to the underlying Operating System.
XrdCl::FileSystem * fFileSystem
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
if(line.BeginsWith("/*"))
virtual const char * GetTitle() const
Returns title of object.
virtual Int_t Locate(const char *path, TString &endurl)
Get the endpoint URL of a file.