1 // ***************************************************************************
2 // BamFtp_p.h (c) 2011 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 10 November 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides reading/writing of BAM files on FTP server
8 // ***************************************************************************
17 // This file is not part of the BamTools API. It exists purely as an
18 // implementation detail. This header file may change from version to version
19 // without notice, or even be removed.
23 #include "api/IBamIODevice.h"
31 class BamFtp : public IBamIODevice {
35 BamFtp(const std::string& url);
38 // IBamIODevice implementation
41 bool IsOpen(void) const;
42 bool IsRandomAccess(void) const;
43 bool Open(const IBamIODevice::OpenMode mode);
44 int64_t Read(char* data, const unsigned int numBytes);
45 bool Seek(const int64_t& position, const int origin = SEEK_SET);
46 int64_t Tell(void) const;
47 int64_t Write(const char* data, const unsigned int numBytes);
51 bool ConnectCommandSocket(void);
52 bool ConnectDataSocket(void);
53 bool ParsePassiveResponse(void);
54 void ParseUrl(const std::string& url);
55 int64_t ReadCommandSocket(char* data, const unsigned int numBytes);
56 int64_t ReadDataSocket(char* data, const unsigned int numBytes);
57 bool ReceiveReply(void);
58 bool SendCommand(const std::string& command, bool waitForReply);
59 int64_t WriteCommandSocket(const char* data, const unsigned int numBytes);
60 int64_t WriteDataSocket(const char* data, const unsigned int numBytes);
66 TcpSocket* m_commandSocket;
67 TcpSocket* m_dataSocket;
69 // our connection data
70 std::string m_hostname;
72 std::string m_dataHostname;
74 std::string m_filename;
76 std::string m_username;
77 std::string m_password;
79 std::string m_response;
81 // internal state flags
85 int64_t m_filePosition;
88 } // namespace Internal
89 } // namespace BamTools