main_windows_x64.go 685 B

123456789101112131415161718192021222324
  1. //go:build windows && (amd64 || arm64 || ppc64 || ppc64le || s390x || mips64 || mips64le)
  2. package yu_file
  3. import yu_sys "gogs.qqck.cn/s/tools/sys"
  4. // Write
  5. //
  6. // @Description: (非多线程安全)写出文件
  7. // @param name 文件路径
  8. // @param bufs 写出内容...
  9. func Write(name string, bufs ...[]byte) bool {
  10. j_fd, _, _ := yu_sys.CreateFileW.Call(yu_sys.S{yu_sys.Unicode, name}, yu_sys.GENERIC_WRITE, yu_sys.FILE_SHARE_NO, 0, yu_sys.CREATE_ALWAYS, yu_sys.FILE_FLAG_WRITE_THROUGH, 0)
  11. if int64(j_fd) == -1 {
  12. return false
  13. }
  14. defer yu_sys.CloseHandle.Call(j_fd)
  15. for j_i := 0; j_i < len(bufs); j_i++ {
  16. if !writeFile(j_fd, bufs[j_i]) {
  17. return false
  18. }
  19. }
  20. return true
  21. }