Skip to content
Snippets Groups Projects
Commit 28c30004 authored by Fons Rademakers's avatar Fons Rademakers
Browse files

From Gerri:

Implement IsPathLocal to check locality.


git-svn-id: http://root.cern.ch/svn/root/trunk@23024 27541ba8-7e3a-0410-8455-c3a389f83636
parent 80411b17
No related branches found
No related tags found
No related merge requests found
...@@ -403,6 +403,7 @@ public: ...@@ -403,6 +403,7 @@ public:
virtual Bool_t ExpandPathName(TString &path); virtual Bool_t ExpandPathName(TString &path);
virtual char *ExpandPathName(const char *path); virtual char *ExpandPathName(const char *path);
virtual Bool_t AccessPathName(const char *path, EAccessMode mode = kFileExists); virtual Bool_t AccessPathName(const char *path, EAccessMode mode = kFileExists);
virtual Bool_t IsPathLocal(const char *path);
virtual int CopyFile(const char *from, const char *to, Bool_t overwrite = kFALSE); virtual int CopyFile(const char *from, const char *to, Bool_t overwrite = kFALSE);
virtual int Rename(const char *from, const char *to); virtual int Rename(const char *from, const char *to);
virtual int Link(const char *from, const char *to); virtual int Link(const char *from, const char *to);
......
...@@ -1116,6 +1116,40 @@ Bool_t TSystem::AccessPathName(const char *, EAccessMode) ...@@ -1116,6 +1116,40 @@ Bool_t TSystem::AccessPathName(const char *, EAccessMode)
return kFALSE; return kFALSE;
} }
//______________________________________________________________________________
Bool_t TSystem::IsPathLocal(const char *path)
{
// Returns TRUE if the url in 'path' points to the local file system.
// This is used to avoid going through the NIC card for local operations.
Bool_t localPath = kTRUE;
TUrl url(path);
if (strlen(url.GetHost()) > 0) {
// Check locality
localPath = kFALSE;
TInetAddress a(gSystem->GetHostByName(url.GetHost()));
TInetAddress b(gSystem->GetHostByName(gSystem->HostName()));
if (!strcmp(a.GetHostName(), b.GetHostName()) ||
!strcmp(a.GetHostAddress(), b.GetHostAddress())) {
// Host OK
localPath = kTRUE;
// Check the user if specified
if (strlen(url.GetUser()) > 0) {
UserGroup_t *u = gSystem->GetUserInfo();
if (u) {
if (strcmp(u->fUser, url.GetUser()))
// Requested a different user
localPath = kFALSE;
delete u;
}
}
}
}
// Done
return localPath;
}
//______________________________________________________________________________ //______________________________________________________________________________
int TSystem::CopyFile(const char *, const char *, Bool_t) int TSystem::CopyFile(const char *, const char *, Bool_t)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment