张富强 3 months ago
parent
commit
c171f8b359
2 changed files with 13 additions and 11 deletions
  1. 10 11
      file/extend_windows.go
  2. 3 0
      win/kernel32.go

+ 10 - 11
file/extend_windows.go

@@ -164,6 +164,16 @@ type ForInfo struct {
 	ForGetMax int64
 }
 
+func NewForInfo() ForInfo {
+	return ForInfo{
+		Start:     0,
+		Size:      -1,
+		ForSize:   0,
+		ForGetN:   0,
+		ForGetMax: 0,
+	}
+}
+
 // En
 //
 //	@Description: 编码数据
@@ -237,17 +247,6 @@ func (t *ForInfo) De(data [40]byte) {
 		int64(data[36])<<32 | int64(data[37])<<40 | int64(data[38])<<48 | int64(data[39])<<56
 }
 
-// Init
-//
-//	@Description: 初始化数据
-func (t *ForInfo) Init() {
-	t.Start = 0
-	t.Size = -1
-	t.ForGetN = 0
-	t.ForSize = 0
-	t.ForGetMax = 0
-}
-
 // ForGet
 //
 //	@Description: 独占方式(多线程安全)读取文件内容

+ 3 - 0
win/kernel32.go

@@ -27,6 +27,7 @@ var GetProcAddress Address
 var FindFirstFileW Address
 var FindNextFileW Address
 var FindClose Address
+var SetEndOfFile Address
 
 func init() {
 	j_mod, _ := syscall.LoadLibrary("kernel32.dll")
@@ -76,6 +77,8 @@ func init() {
 	FindNextFileW = Address(j_h)
 	j_h, _ = syscall.GetProcAddress(j_mod, "FindClose")
 	FindClose = Address(j_h)
+	j_h, _ = syscall.GetProcAddress(j_mod, "SetEndOfFile")
+	SetEndOfFile = Address(j_h)
 }
 
 func GetModuleHandle(name string) Module {