00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TNetFile
00013 #define ROOT_TNetFile
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ROOT_TFile
00026 #include "TFile.h"
00027 #endif
00028 #ifndef ROOT_TUrl
00029 #include "TUrl.h"
00030 #endif
00031 #ifndef ROOT_TFTP
00032 #include "TFTP.h"
00033 #endif
00034 #ifndef ROOT_TSystem
00035 #include "TSystem.h"
00036 #endif
00037 #ifndef ROOT_MessageTypes
00038 #include "MessageTypes.h"
00039 #endif
00040
00041 class TSocket;
00042
00043
00044 class TNetFile : public TFile {
00045
00046 protected:
00047 TUrl fEndpointUrl;
00048 TString fUser;
00049 TSocket *fSocket;
00050 Int_t fProtocol;
00051 Int_t fErrorCode;
00052 Int_t fNetopt;
00053
00054 TNetFile(const TNetFile&);
00055 TNetFile& operator=(const TNetFile&);
00056
00057 TNetFile(const char *url, const char *ftitle, Int_t comp, Bool_t);
00058 virtual void ConnectServer(Int_t *stat, EMessageTypes *kind, Int_t netopt,
00059 Int_t tcpwindowsize, Bool_t forceOpen,
00060 Bool_t forceRead);
00061 virtual void Create(const char *url, Option_t *option, Int_t netopt);
00062 virtual void Create(TSocket *s, Option_t *option, Int_t netopt);
00063 void Init(Bool_t create);
00064 void Print(Option_t *option) const;
00065 void PrintError(const char *where, Int_t err);
00066 Int_t Recv(Int_t &status, EMessageTypes &kind);
00067 Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
00068 Int_t SysClose(Int_t fd);
00069 Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
00070
00071 public:
00072 TNetFile(const char *url, Option_t *option = "", const char *ftitle = "",
00073 Int_t compress = 1, Int_t netopt = 0);
00074 TNetFile() : fEndpointUrl(), fUser(), fSocket(0), fProtocol(0), fErrorCode(0), fNetopt(0) { }
00075 virtual ~TNetFile();
00076
00077 void Close(Option_t *option="");
00078 void Flush();
00079 Int_t GetErrorCode() const { return fErrorCode; }
00080 Bool_t IsOpen() const;
00081 Bool_t Matches(const char *url);
00082 Int_t ReOpen(Option_t *mode);
00083 Bool_t ReadBuffer(char *buf, Int_t len);
00084 Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
00085 Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
00086 Bool_t WriteBuffer(const char *buf, Int_t len);
00087 void Seek(Long64_t offset, ERelativeTo pos = kBeg);
00088
00089 const TUrl *GetEndpointUrl() const { return &fEndpointUrl; }
00090
00091 ClassDef(TNetFile,1)
00092 };
00093
00094
00095 class TNetSystem : public TSystem {
00096
00097 private:
00098 Bool_t fDir;
00099 void *fDirp;
00100 TFTP *fFTP;
00101 TString fHost;
00102 Bool_t fFTPOwner;
00103 TString fUser;
00104 Int_t fPort;
00105
00106 TNetSystem(const TNetSystem&);
00107 TNetSystem& operator=(const TNetSystem&);
00108
00109 void *GetDirPtr() const { return fDirp; }
00110
00111 protected:
00112 Bool_t fIsLocal;
00113 TString fLocalPrefix;
00114
00115 void Create(const char *url, TSocket *sock = 0);
00116 void InitRemoteEntity(const char *url);
00117
00118 public:
00119 TNetSystem(Bool_t ftpowner = kTRUE);
00120 TNetSystem(const char *url, Bool_t ftpowner = kTRUE);
00121 virtual ~TNetSystem();
00122
00123 Bool_t ConsistentWith(const char *path, void *dirptr);
00124 Int_t MakeDirectory(const char *name);
00125 void *OpenDirectory(const char *name);
00126 void FreeDirectory(void *dirp = 0);
00127 const char *GetDirEntry(void *dirp = 0);
00128 Int_t GetPathInfo(const char *path, FileStat_t &buf);
00129 Bool_t AccessPathName(const char *path, EAccessMode mode);
00130 int Unlink(const char *path);
00131
00132 ClassDef(TNetSystem,0)
00133 };
00134
00135 #endif