TSystem::FindHelper and TSystem helper plugins

Hi,

I need to write some OS-independent code to perform file-system operations
such as creating directories, copying/deleting files, etc., where the actual nature of the file-system can be the same as the OS, or on a remote server via ‘rfio’ or ‘xrootd’.

I was all set to run with gSystem->FindHelper(…) deducing from the path to the root of the file-system ("/unix/type/system…", “c:\windows\system”, “rfio:server:/files/…” etc.) whether to use gSystem itself, or a TRFIOSystem etc. etc., then I realised that TSystem::FindHelper is protected!

After a couple of hours of reflection and trying to derive a class from TSystem that would let me have access while writing the least possible number of lines of code, I’m stuck…
Does anybody know if there is an existing way to do what I want ?

Thankyou
John

Hi John,

what exactly do you want to do. Most of the file system operations that are also supported by the remote protocols have helpers. This should all be transparent to you.

Cheers, Fons.

Hi Fons,

I guess I’ve missed something obvious, but what I want is to handle automatically the following:

My code is used in Linux, MacOSX and Windows environments (and the fact that this is possible is entirely due to ROOT and especially gSystem - cheers!!). The part I am working on handles a repository of data files (some are ROOT files, some are not) which may be on the user’s machine (so using the same file system as handled by gSystem - no problem), or may be accessed through an xrootd server, or, in one case, via rfio. The user configures his access to the data in a ‘.rootrc’-style config file, and I wanted to deduce from e.g. the given root directory of the repository what type of file system helper is necessary to perform operations like creating directories, moving, deleting and copying files.

I know how to do it, especially after having read the code in TSystem::FindHelper :laughing: , but the point: it already exists so why duplicate the code ? Am I missing something obvious (again) … ? :frowning:

Cheers
John

Hi John,

I’ve made FindHelper() public and added some extra comments on how to use it. Change is in the cvs head.

Cheers, Fons.

Thanks a lot!
John

Hi Fons,

First of all: many apologies, you were of course right first time, I completely forgot that (in many cases) the gSystem->… calls actually redirect to an appropriate helper. So access to FindHelper is not necessary.

However, I did notice one or two things that are missing IMHO…

  1. TUnixSystem::Chmod and TWinNTSystem do not check if a helper is available and assume a local file argument. Currently this doesn’t matter as no helper TSystems define a Chmod method, but I would like to suggest the following addition to TRFIOSystem:
extern "C" {
   int     rfio_chmod(const char *path, mode_t mode);
};

int TRFIOSystem::Chmod(const char *file, UInt_t mode)
{
   // Set the file permission bits. Returns -1 in case or error, 0 otherwise.

   TUrl url(file);   
   return ::rfio_chmod(url.GetFile(), mode);
}
  1. Similarly, the TUnixSystem and TWinNTSystem CopyFile methods assume local files. However it would be nice to have a general CopyFile which can copy any file from anywhere to anywhere…
    The suggested method in the attached file TSystem_CopyFile.cpp has been tested for transfers to and from hpss via rfio, but can certainly be optimised for cases where both source and target are local files, or when the source is a ROOT file, etc. My solution for the size of the buffer is also totally empirical and probably not very good or general.

Hope I haven’t got it all wrong again… :blush:
Cheers
John
TSystem_CopyFile.cpp (3.2 KB)