// Copyright 2020 The Gogs Authors. All rights reserved.// Use of this source code is governed by a MIT-style// license that can be found in the LICENSE file.packageosutilimport("os")// IsFile returns true if given path exists as a file (i.e. not a directory).funcIsFile(pathstring)bool{f,e:=os.Stat(path)ife!=nil{returnfalse}return!f.IsDir()}// IsDir returns true if given path is a directory, and returns false when it's// a file or does not exist.funcIsDir(dirstring)bool{f,e:=os.Stat(dir)ife!=nil{returnfalse}returnf.IsDir()}// IsExist returns true if a file or directory exists.funcIsExist(pathstring)bool{_,err:=os.Stat(path)returnerr==nil||os.IsExist(err)}// CurrentUsername returns the current system user via environment variables.funcCurrentUsername()string{username:=os.Getenv("USER")iflen(username)>0{returnusername}returnos.Getenv("USERNAME")}