|  |  | @ -3,6 +3,9 @@ package util | 
			
		
	
		
			
				
					|  |  |  | import ( | 
			
		
	
		
			
				
					|  |  |  | 	"errors" | 
			
		
	
		
			
				
					|  |  |  | 	"os" | 
			
		
	
		
			
				
					|  |  |  | 	"os/user" | 
			
		
	
		
			
				
					|  |  |  | 	"path/filepath" | 
			
		
	
		
			
				
					|  |  |  | 	"strings" | 
			
		
	
		
			
				
					|  |  |  | 	"time" | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	"github.com/chrislusf/seaweedfs/weed/glog" | 
			
		
	
	
		
			
				
					|  |  | @ -63,3 +66,20 @@ func CheckFile(filename string) (exists, canRead, canWrite bool, modTime time.Ti | 
			
		
	
		
			
				
					|  |  |  | 	fileSize = fi.Size() | 
			
		
	
		
			
				
					|  |  |  | 	return | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | func ResolvePath(path string) string { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	usr, _ := user.Current() | 
			
		
	
		
			
				
					|  |  |  | 	dir := usr.HomeDir | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	if path == "~" { | 
			
		
	
		
			
				
					|  |  |  | 		// In case of "~", which won't be caught by the "else if"
 | 
			
		
	
		
			
				
					|  |  |  | 		path = dir | 
			
		
	
		
			
				
					|  |  |  | 	} else if strings.HasPrefix(path, "~/") { | 
			
		
	
		
			
				
					|  |  |  | 		// Use strings.HasPrefix so we don't match paths like
 | 
			
		
	
		
			
				
					|  |  |  | 		// "/something/~/something/"
 | 
			
		
	
		
			
				
					|  |  |  | 		path = filepath.Join(dir, path[2:]) | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	return path | 
			
		
	
		
			
				
					|  |  |  | } |