Merge pull request #41 from digineo/avoid_strings_split
Avoid strings.Split
This commit is contained in:
		
						commit
						a104f27d44
					
				
							
								
								
									
										14
									
								
								ftp.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								ftp.go
									
									
									
									
									
								
							@ -290,14 +290,18 @@ var errUnsupportedListLine = errors.New("Unsupported LIST line")
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// parseRFC3659ListLine parses the style of directory line defined in RFC 3659.
 | 
					// parseRFC3659ListLine parses the style of directory line defined in RFC 3659.
 | 
				
			||||||
func parseRFC3659ListLine(line string) (*Entry, error) {
 | 
					func parseRFC3659ListLine(line string) (*Entry, error) {
 | 
				
			||||||
	if i := strings.Index(line, ";"); i < 0 || i > strings.Index(line, " ") {
 | 
						iSemicolon := strings.Index(line, ";")
 | 
				
			||||||
 | 
						iWhitespace := strings.Index(line, " ")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if iSemicolon < 0 || iSemicolon > iWhitespace {
 | 
				
			||||||
		return nil, errUnsupportedListLine
 | 
							return nil, errUnsupportedListLine
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	e := &Entry{}
 | 
					 | 
				
			||||||
	arr := strings.Split(line, "; ")
 | 
					 | 
				
			||||||
	e.Name = arr[1]
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, field := range strings.Split(arr[0], ";") {
 | 
						e := &Entry{
 | 
				
			||||||
 | 
							Name: line[iWhitespace+1 : len(line)],
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, field := range strings.Split(line[:iWhitespace-1], ";") {
 | 
				
			||||||
		i := strings.Index(field, "=")
 | 
							i := strings.Index(field, "=")
 | 
				
			||||||
		if i < 1 {
 | 
							if i < 1 {
 | 
				
			||||||
			return nil, errUnsupportedListLine
 | 
								return nil, errUnsupportedListLine
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user