commit
						106ab1b13b
					
				@ -96,6 +96,33 @@ func testConn(t *testing.T, disableEPSV bool) {
 | 
				
			|||||||
		r.Close()
 | 
							r.Close()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fileSize, err := c.FileSize("tset")
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							t.Error(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if fileSize != 14 {
 | 
				
			||||||
 | 
							t.Errorf("file size %q, expected %q", fileSize, 14)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data = bytes.NewBufferString("")
 | 
				
			||||||
 | 
						err = c.Stor("tset", data)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							t.Error(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fileSize, err = c.FileSize("tset")
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							t.Error(err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if fileSize != 0 {
 | 
				
			||||||
 | 
							t.Errorf("file size %q, expected %q", fileSize, 0)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fileSize, err = c.FileSize("not-found")
 | 
				
			||||||
 | 
						if err == nil {
 | 
				
			||||||
 | 
							t.Fatal("expected error, got nil")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = c.Delete("tset")
 | 
						err = c.Delete("tset")
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Error(err)
 | 
							t.Error(err)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								ftp.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								ftp.go
									
									
									
									
									
								
							@ -407,6 +407,16 @@ func (c *ServerConn) CurrentDir() (string, error) {
 | 
				
			|||||||
	return msg[start+1 : end], nil
 | 
						return msg[start+1 : end], nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// FileSize issues a SIZE FTP command, which Returns the size of the file
 | 
				
			||||||
 | 
					func (c *ServerConn) FileSize(path string) (int64, error) {
 | 
				
			||||||
 | 
						_, msg, err := c.cmd(StatusFile, "SIZE %s", path)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return 0, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return strconv.ParseInt(msg, 10, 64)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Retr issues a RETR FTP command to fetch the specified file from the remote
 | 
					// Retr issues a RETR FTP command to fetch the specified file from the remote
 | 
				
			||||||
// FTP server.
 | 
					// FTP server.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user