main_windows.go 674 B

123456789101112131415161718192021222324252627282930313233
  1. //go:build windows
  2. package yu_path
  3. import (
  4. yu_win "gogs.qqck.cn/s/tools/win"
  5. )
  6. // IsFile
  7. //
  8. // @Description: 判断给定路径是否是文件类型
  9. func IsFile(s string) bool {
  10. j_type := GetFileAttributes(s)
  11. if j_type == -1 {
  12. return false
  13. }
  14. return j_type&yu_win.FILE_ATTRIBUTE_DIRECTORY == 0
  15. }
  16. // IsDir
  17. //
  18. // @Description: 判断给定路径是否是目录类型
  19. func IsDir(s string) bool {
  20. j_type := GetFileAttributes(s)
  21. if j_type == -1 {
  22. return false
  23. }
  24. return j_type&yu_win.FILE_ATTRIBUTE_DIRECTORY == yu_win.FILE_ATTRIBUTE_DIRECTORY
  25. }
  26. func GetFileAttributes(s string) int32 {
  27. return yu_win.GetFileAttributesW.CallInt32(yu_win.S{yu_win.Unicode, s})
  28. }