File indexing completed on 2026-10-02 09:23:08
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 namespace ROOT::Deprecated {
0034
0035 class TFTP : public TObject {
0036
0037 private:
0038 TString fHost;
0039 TString fUser;
0040 Int_t fPort;
0041 Int_t fParallel;
0042 Int_t fWindowSize;
0043 Int_t fProtocol;
0044 Int_t fLastBlock;
0045 Int_t fBlockSize;
0046 Int_t fMode;
0047 Long64_t fRestartAt;
0048 TString fCurrentFile;
0049 TSocket *fSocket;
0050 Long64_t fBytesWrite;
0051 Long64_t fBytesRead;
0052 Bool_t fDir;
0053
0054 TFTP(): fHost(), fUser(), fPort(0), fParallel(0), fWindowSize(0),
0055 fProtocol(0), fLastBlock(0), fBlockSize(0), fMode(0),
0056 fRestartAt(0), fCurrentFile(), fSocket(nullptr), fBytesWrite(0),
0057 fBytesRead(0), fDir(kFALSE) { }
0058 TFTP(const TFTP &) = delete;
0059 void operator=(const TFTP &) = delete;
0060 void Init(const char *url, Int_t parallel, Int_t wsize);
0061 void PrintError(const char *where, Int_t err) const;
0062 Int_t Recv(Int_t &status, EMessageTypes &kind) const;
0063 void SetMode(Int_t mode) { fMode = mode; }
0064
0065 static Long64_t fgBytesWrite;
0066 static Long64_t fgBytesRead;
0067
0068 public:
0069 enum {
0070 kDfltBlockSize = 0x80000,
0071 kDfltWindowSize = 65535,
0072 kBinary = 0,
0073 kAscii = 1
0074 };
0075
0076 TFTP(const char *url, Int_t parallel = 1, Int_t wsize = kDfltWindowSize,
0077 TSocket *sock = nullptr);
0078 virtual ~TFTP();
0079
0080 void SetBlockSize(Int_t blockSize);
0081 Int_t GetBlockSize() const { return fBlockSize; }
0082 void SetRestartAt(Long64_t at) { fRestartAt = at; }
0083 Long64_t GetRestartAt() const { return fRestartAt; }
0084 Int_t GetMode() const { return fMode; }
0085
0086 Bool_t IsOpen() const { return fSocket ? kTRUE : kFALSE; }
0087 void Print(Option_t *opt = "") const override;
0088
0089 Long64_t PutFile(const char *file, const char *remoteName = nullptr);
0090 Long64_t GetFile(const char *file, const char *localName = nullptr);
0091
0092 Bool_t AccessPathName(const char *path, EAccessMode mode = kFileExists,
0093 Bool_t print = kFALSE);
0094 const char *GetDirEntry(Bool_t print = kFALSE);
0095 Int_t GetPathInfo(const char *path, FileStat_t &buf, Bool_t print = kFALSE);
0096 Int_t ChangeDirectory(const char *dir) const;
0097 Int_t MakeDirectory(const char *dir, Bool_t print = kFALSE) const;
0098 Int_t DeleteDirectory(const char *dir) const;
0099 Int_t ListDirectory(Option_t *cmd = "") const;
0100 void FreeDirectory(Bool_t print = kFALSE);
0101 Bool_t OpenDirectory(const char *name, Bool_t print = kFALSE);
0102 Int_t PrintDirectory() const;
0103 Int_t RenameFile(const char *file1, const char *file2) const;
0104 Int_t DeleteFile(const char *file) const;
0105 Int_t ChangePermission(const char *file, Int_t mode) const;
0106 Int_t Close();
0107 void Binary() { SetMode(kBinary); }
0108 void Ascii() { SetMode(kAscii); }
0109 TSocket *GetSocket() const { return fSocket; }
0110
0111
0112 void put(const char *file, const char *remoteName = nullptr) { PutFile(file, remoteName); }
0113 void get(const char *file, const char *localName = nullptr) { GetFile(file, localName); }
0114 void cd(const char *dir) const { ChangeDirectory(dir); }
0115 void mkdir(const char *dir) const { MakeDirectory(dir); }
0116 void rmdir(const char *dir) const { DeleteDirectory(dir); }
0117 void ls(Option_t *cmd = "") const override { ListDirectory(cmd); }
0118 void pwd() const { PrintDirectory(); }
0119 void mv(const char *file1, const char *file2) const { RenameFile(file1, file2); }
0120 void rm(const char *file) const { DeleteFile(file); }
0121 void chmod(const char *file, Int_t mode) const { ChangePermission(file, mode); }
0122 void bye() { Close(); }
0123 void bin() { Binary(); }
0124 void ascii() { Ascii(); }
0125
0126 ClassDefOverride(TFTP, 1)
0127 };
0128
0129 }
0130
0131 using TFTP R__DEPRECATED(6, 42, "TFTP is deprecated") = ROOT::Deprecated::TFTP;
0132
0133 #endif