Example #1
0
        private FtpDataStream GetStream(long offset, TransferDirection dir)
        {
            m_parent.CheckSessionCurrentDirectory();
            SessionConnected session = m_parent.FtpSession;

            if (offset != 0)
            {
                session.ControlChannel.REST(offset);
            }
            FtpDataStream stream = session.ControlChannel.GetPassiveDataStream(dir);

            try
            {
                if (dir == TransferDirection.Download)
                {
                    session.ControlChannel.RETR(m_name);
                }
                else
                {
                    session.ControlChannel.STOR(m_name);
                }
            }
            catch (Exception)
            {
                stream.Dispose();
                throw;
            }
            return(stream);
        }
Example #2
0
        internal FtpFileTransferer(FtpDirectory transferStarter, string localFile, string remoteFile, long totalBytes, TransferDirection dir)
        {
            m_transferStarter   = transferStarter;
            m_transferDirection = dir;
            m_session           = transferStarter.FtpSession;
            m_localFile         = localFile;
            m_remoteFile        = remoteFile;
            m_totalBytes        = totalBytes;

            if (dir == TransferDirection.Upload)
            {
                m_beginEvent            = new FileEventDelegate(m_session.Host.RaiseBeginPutFileEvent);
                m_endEvent              = new FileEventDelegate(m_session.Host.RaiseEndPutFile);
                m_streamCopyRoutine     = new StreamCopyDelegate(LocalToRemote);
                m_ftpFileCommandRoutine = new FtpDelegate(m_session.ControlChannel.STOR);
                m_localFileOpenMode     = FileMode.Open;
            }
            else
            {
                m_beginEvent            = new FileEventDelegate(m_session.Host.RaiseBeginGetFileEvent);
                m_endEvent              = new FileEventDelegate(m_session.Host.RaiseEndGetFile);
                m_streamCopyRoutine     = new StreamCopyDelegate(RemoteToLocal);
                m_ftpFileCommandRoutine = new FtpDelegate(m_session.ControlChannel.RETR);
                m_localFileOpenMode     = FileMode.Create;
            }
        }
Example #3
0
 internal FtpDataStream(ControlChannel ctrl, TcpClient client)
 {
     m_session   = ctrl.Session;
     m_ctrl      = ctrl;
     m_tcpClient = client;
     m_stream    = client.GetStream();
     m_session.BeginDataTransfer(this);
 }
Example #4
0
 internal FtpDirectory(SessionConnected s, string parentPath, string name)
 {
     m_session = s;
     if (name != "")
     {
         m_name     = name;
         m_fullPath = parentPath + m_name + "/";
     }
     else
     {
         m_name = m_fullPath = "/";
     }
 }
Example #5
0
        internal FtpDirectory(SessionConnected s)
        {
            m_session = s;

            m_fullPath = s.ControlChannel.PWD();
            if (m_fullPath == "/")
            {
                m_name = m_fullPath;
                return;
            }

            string[] directories = m_fullPath.Split('/');
            m_name      = directories[directories.Length - 1];
            m_fullPath += "/";
        }