Provides data for the filesytem related events for FTP_Server.
예제 #1
0
        private void NLST(string argsText)
        {
            /*
             *      This command causes a directory listing to be sent from
             *      server to user site.  The pathname should specify a
             *      directory or other system-specific file group descriptor; a
             *      null argument implies the current directory.  The server
             *      will return a stream of names of files and no other
             *      information.  The data will be transferred in ASCII or
             *      EBCDIC type over the data connection as valid pathname
             *      strings separated by <CRLF> or <NL>.  (Again the user must
             *      ensure that the TYPE is correct.)  This command is intended
             *      to return information that can be used by a program to
             *      further process the files automatically.  For example, in
             *      the implementation of a "multiple get" function.
             */
            if (!this.Authenticated)
            {
                this.Socket.WriteLine("530 Please authenticate firtst !");
                return;
            }

            //---- See if path accessible
            FileSysEntry_EventArgs eArgs = m_pServer.OnGetDirInfo(this, GetAndNormailizePath(argsText));

            if (!eArgs.Validated)
            {
                this.Socket.WriteLine("550 Access denied or directory dosen't exist !");
                return;
            }
            DataSet ds = eArgs.DirInfo;

            Socket socket = GetDataConnection();

            if (socket == null)
            {
                return;
            }

            try
            {
                //		string dir = GetAndNormailizePath(argsText);
                //		DataSet ds = m_pServer.OnGetDirInfo(dir);

                foreach (DataRow dr in ds.Tables["DirInfo"].Rows)
                {
                    socket.Send(System.Text.Encoding.Default.GetBytes(dr["Name"].ToString() + "\r\n"));
                }
                socket.Send(System.Text.Encoding.Default.GetBytes("aaa\r\n"));

                socket.Shutdown(SocketShutdown.Both);
                socket.Close();

                this.Socket.WriteLine("226 Transfer Complete.");
            }
            catch
            {
                this.Socket.WriteLine("426 Connection closed; transfer aborted.");
            }
        }
예제 #2
0
        internal FileSysEntry_EventArgs OnGetDirInfo(FTP_Session session, string dir)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, dir, "");

            if (this.GetDirInfo != null)
            {
                this.GetDirInfo(this, oArg);
            }
            return(oArg);
        }
예제 #3
0
        internal bool OnCreateDir(string dir)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(dir, "");

            if (this.CreateDir != null)
            {
                this.CreateDir(this, oArg);
            }

            return(oArg.Validated);
        }
예제 #4
0
        internal Stream OnStoreFile(FTP_Session session, string file)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, file, "");

            if (this.StoreFile != null)
            {
                this.StoreFile(this, oArg);
            }

            return(oArg.FileStream);
        }
예제 #5
0
        internal bool OnDeleteFile(FTP_Session session, string file)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, file, "");

            if (this.DeleteFile != null)
            {
                this.DeleteFile(this, oArg);
            }

            return(oArg.Validated);
        }
예제 #6
0
        internal bool OnRenameDirFile(FTP_Session session, string from, string to)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, from, to);

            if (this.RenameDirFile != null)
            {
                this.RenameDirFile(this, oArg);
            }

            return(oArg.Validated);
        }
예제 #7
0
        internal bool OnDirExists(string dir)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(dir, "");

            if (this.DirExists != null)
            {
                this.DirExists(this, oArg);
            }

            return(oArg.Validated);
        }
예제 #8
0
        internal bool OnDeleteDir(FTP_Session session, string dir)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, dir, "");

            if (this.DeleteDir != null)
            {
                this.DeleteDir(this, oArg);
            }

            return(oArg.Validated);
        }
예제 #9
0
        internal Stream OnGetFile(string file)
        {
            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(file, "");

            if (this.GetFile != null)
            {
                this.GetFile(this, oArg);
            }

            return(oArg.FileStream);
        }
예제 #10
0
        internal bool OnFileExists(FTP_Session session, string file)
        {
            // Remove last /
            file = file.Substring(0, file.Length - 1);

            FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session, file, "");

            if (this.FileExists != null)
            {
                this.FileExists(this, oArg);
            }

            return(oArg.Validated);
        }
예제 #11
0
        private void LIST(string argsText)
        {
            /*
             *      This command causes a list to be sent from the server to the
             *      passive DTP.  If the pathname specifies a directory or other
             *      group of files, the server should transfer a list of files
             *      in the specified directory.  If the pathname specifies a
             *      file then the server should send current information on the
             *      file.  A null argument implies the user's current working or
             *      default directory.  The data transfer is over the data
             *      connection in type ASCII or type EBCDIC.  (The user must
             *      ensure that the TYPE is appropriately ASCII or EBCDIC).
             *      Since the information on a file may vary widely from system
             *      to system, this information may be hard to use automatically
             *      in a program, but may be quite useful to a human user.
             */
            if (!this.Authenticated)
            {
                this.Socket.WriteLine("530 Please authenticate firtst !");
                return;
            }

            // ToDo: custom errors
            //---- See if path accessible
            FileSysEntry_EventArgs eArgs = m_pServer.OnGetDirInfo(this, GetAndNormailizePath(argsText));

            if (!eArgs.Validated)
            {
                this.Socket.WriteLine("550 Access denied or directory dosen't exist !");
                return;
            }
            DataSet ds = eArgs.DirInfo;

            Socket socket = GetDataConnection();

            if (socket == null)
            {
                return;
            }

            try{
                //	string dir = GetAndNormailizePath(argsText);
                //	DataSet ds = m_pServer.OnGetDirInfo(dir);

                foreach (DataRow dr in ds.Tables["DirInfo"].Rows)
                {
                    string name  = dr["Name"].ToString();
                    string date  = Convert.ToDateTime(dr["Date"]).ToString("MM-dd-yy hh:mmtt");
                    bool   isDir = Convert.ToBoolean(dr["IsDirectory"]);

                    if (isDir)
                    {
                        socket.Send(System.Text.Encoding.Default.GetBytes(date + " <DIR> " + name + "\r\n"));
                    }
                    else
                    {
                        socket.Send(System.Text.Encoding.Default.GetBytes(date + " " + dr["Size"].ToString() + " " + name + "\r\n"));
                    }
                }

                socket.Shutdown(SocketShutdown.Both);
                socket.Close();

                this.Socket.WriteLine("226 Transfer Complete.");
            }
            catch {
                this.Socket.WriteLine("426 Connection closed; transfer aborted.");
            }
        }
예제 #12
0
		internal bool OnDeleteDir(FTP_Session session,string dir)
		{
			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,dir,"");
			if(this.DeleteDir != null){
				this.DeleteDir(this,oArg);
			}
			
			return oArg.Validated;
		}
예제 #13
0
		internal FileSysEntry_EventArgs OnGetDirInfo(FTP_Session session,string dir)
		{
			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,dir,"");
			if(this.GetDirInfo != null){
				this.GetDirInfo(this,oArg);
			}
			return oArg;
		}
예제 #14
0
		internal bool OnDeleteFile(FTP_Session session,string file)
		{
			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,file,"");
			if(this.DeleteFile != null){
				this.DeleteFile(this,oArg);
			}
			
			return oArg.Validated;
		}
예제 #15
0
		internal Stream OnStoreFile(FTP_Session session,string file)
		{
			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,file,"");
			if(this.StoreFile != null){
				this.StoreFile(this,oArg);
			}
			
			return oArg.FileStream;
		}
예제 #16
0
		internal bool OnFileExists(FTP_Session session,string file)
		{
			// Remove last /
			file = file.Substring(0,file.Length - 1);

			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,file,"");
			if(this.FileExists != null){
				this.FileExists(this,oArg);
			}
			
			return oArg.Validated;
		}
예제 #17
0
		internal bool OnRenameDirFile(FTP_Session session,string from,string to)
		{
			FileSysEntry_EventArgs oArg = new FileSysEntry_EventArgs(session,from,to);
			if(this.RenameDirFile != null){
				this.RenameDirFile(this,oArg);
			}
			
			return oArg.Validated;
		}