蛋蛋星球-客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

30 lines
502 B

  1. package utils
  2. import "os"
  3. // 判断所给路径文件、文件夹是否存在
  4. func Exists(path string) bool {
  5. _, err := os.Stat(path) //os.Stat获取文件信息
  6. if err != nil {
  7. if os.IsExist(err) {
  8. return true
  9. }
  10. return false
  11. }
  12. return true
  13. }
  14. // 判断所给路径是否为文件夹
  15. func IsDir(path string) bool {
  16. s, err := os.Stat(path)
  17. if err != nil {
  18. return false
  19. }
  20. return s.IsDir()
  21. }
  22. // 判断所给路径是否为文件
  23. func IsFile(path string) bool {
  24. return !IsDir(path)
  25. }