Merge pull request #257 from tauu/cmd-type
support for the TYPE command
This commit is contained in:
		
						commit
						dfa1e758f3
					
				
							
								
								
									
										17
									
								
								ftp.go
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								ftp.go
									
									
									
									
									
								
							@ -28,6 +28,15 @@ const (
 | 
				
			|||||||
	EntryTypeLink
 | 
						EntryTypeLink
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TransferType denotes the formats for transfering Entries.
 | 
				
			||||||
 | 
					type TransferType string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// The different transfer types
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						TransferTypeBinary = "I"
 | 
				
			||||||
 | 
						TransferTypeASCII  = "A"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Time format used by the MDTM and MFMT commands
 | 
					// Time format used by the MDTM and MFMT commands
 | 
				
			||||||
const timeFormat = "20060102150405"
 | 
					const timeFormat = "20060102150405"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -340,7 +349,7 @@ func (c *ServerConn) Login(user, password string) error {
 | 
				
			|||||||
	c.mdtmCanWrite = c.mdtmSupported && c.options.writingMDTM
 | 
						c.mdtmCanWrite = c.mdtmSupported && c.options.writingMDTM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Switch to binary mode
 | 
						// Switch to binary mode
 | 
				
			||||||
	if _, _, err = c.cmd(StatusCommandOK, "TYPE I"); err != nil {
 | 
						if err = c.Type(TransferTypeBinary); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -580,6 +589,12 @@ func (c *ServerConn) cmdDataConnFrom(offset uint64, format string, args ...inter
 | 
				
			|||||||
	return conn, nil
 | 
						return conn, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Type switches the transfer mode for the connection.
 | 
				
			||||||
 | 
					func (c *ServerConn) Type(transferType TransferType) (err error) {
 | 
				
			||||||
 | 
						_, _, err = c.cmd(StatusCommandOK, "TYPE "+string(transferType))
 | 
				
			||||||
 | 
						return err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NameList issues an NLST FTP command.
 | 
					// NameList issues an NLST FTP command.
 | 
				
			||||||
func (c *ServerConn) NameList(path string) (entries []string, err error) {
 | 
					func (c *ServerConn) NameList(path string) (entries []string, err error) {
 | 
				
			||||||
	space := " "
 | 
						space := " "
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user