Warning, file /include/root/TFTP.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TFTP
0013 #define ROOT_TFTP
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include "TObject.h"
0026 #include "TSystem.h"
0027 #include "TString.h"
0028 #include "MessageTypes.h"
0029
0030
0031 class TSocket;
0032
0033
0034 class TFTP : public TObject {
0035
0036 private:
0037 TString fHost;
0038 TString fUser;
0039 Int_t fPort;
0040 Int_t fParallel;
0041 Int_t fWindowSize;
0042 Int_t fProtocol;
0043 Int_t fLastBlock;
0044 Int_t fBlockSize;
0045 Int_t fMode;
0046 Long64_t fRestartAt;
0047 TString fCurrentFile;
0048 TSocket *fSocket;
0049 Long64_t fBytesWrite;
0050 Long64_t fBytesRead;
0051 Bool_t fDir;
0052
0053 TFTP(): fHost(), fUser(), fPort(0), fParallel(0), fWindowSize(0),
0054 fProtocol(0), fLastBlock(0), fBlockSize(0), fMode(0),
0055 fRestartAt(0), fCurrentFile(), fSocket(nullptr), fBytesWrite(0),
0056 fBytesRead(0), fDir(kFALSE) { }
0057 TFTP(const TFTP &) = delete;
0058 void operator=(const TFTP &) = delete;
0059 void Init(const char *url, Int_t parallel, Int_t wsize);
0060 void PrintError(const char *where, Int_t err) const;
0061 Int_t Recv(Int_t &status, EMessageTypes &kind) const;
0062 void SetMode(Int_t mode) { fMode = mode; }
0063
0064 static Long64_t fgBytesWrite;
0065 static Long64_t fgBytesRead;
0066
0067 public:
0068 enum {
0069 kDfltBlockSize = 0x80000,
0070 kDfltWindowSize = 65535,
0071 kBinary = 0,
0072 kAscii = 1
0073 };
0074
0075 TFTP(const char *url, Int_t parallel = 1, Int_t wsize = kDfltWindowSize,
0076 TSocket *sock = nullptr);
0077 virtual ~TFTP();
0078
0079 void SetBlockSize(Int_t blockSize);
0080 Int_t GetBlockSize() const { return fBlockSize; }
0081 void SetRestartAt(Long64_t at) { fRestartAt = at; }
0082 Long64_t GetRestartAt() const { return fRestartAt; }
0083 Int_t GetMode() const { return fMode; }
0084
0085 Bool_t IsOpen() const { return fSocket ? kTRUE : kFALSE; }
0086 void Print(Option_t *opt = "") const override;
0087
0088 Long64_t PutFile(const char *file, const char *remoteName = nullptr);
0089 Long64_t GetFile(const char *file, const char *localName = nullptr);
0090
0091 Bool_t AccessPathName(const char *path, EAccessMode mode = kFileExists,
0092 Bool_t print = kFALSE);
0093 const char *GetDirEntry(Bool_t print = kFALSE);
0094 Int_t GetPathInfo(const char *path, FileStat_t &buf, Bool_t print = kFALSE);
0095 Int_t ChangeDirectory(const char *dir) const;
0096 Int_t MakeDirectory(const char *dir, Bool_t print = kFALSE) const;
0097 Int_t DeleteDirectory(const char *dir) const;
0098 Int_t ListDirectory(Option_t *cmd = "") const;
0099 void FreeDirectory(Bool_t print = kFALSE);
0100 Bool_t OpenDirectory(const char *name, Bool_t print = kFALSE);
0101 Int_t PrintDirectory() const;
0102 Int_t RenameFile(const char *file1, const char *file2) const;
0103 Int_t DeleteFile(const char *file) const;
0104 Int_t ChangePermission(const char *file, Int_t mode) const;
0105 Int_t Close();
0106 void Binary() { SetMode(kBinary); }
0107 void Ascii() { SetMode(kAscii); }
0108 TSocket *GetSocket() const { return fSocket; }
0109
0110
0111 void put(const char *file, const char *remoteName = nullptr) { PutFile(file, remoteName); }
0112 void get(const char *file, const char *localName = nullptr) { GetFile(file, localName); }
0113 void cd(const char *dir) const { ChangeDirectory(dir); }
0114 void mkdir(const char *dir) const { MakeDirectory(dir); }
0115 void rmdir(const char *dir) const { DeleteDirectory(dir); }
0116 void ls(Option_t *cmd = "") const override { ListDirectory(cmd); }
0117 void pwd() const { PrintDirectory(); }
0118 void mv(const char *file1, const char *file2) const { RenameFile(file1, file2); }
0119 void rm(const char *file) const { DeleteFile(file); }
0120 void chmod(const char *file, Int_t mode) const { ChangePermission(file, mode); }
0121 void bye() { Close(); }
0122 void bin() { Binary(); }
0123 void ascii() { Ascii(); }
0124
0125 ClassDefOverride(TFTP, 1)
0126 };
0127
0128 #endif