Skip to content

Commit

Permalink
新增file.MoveFile
Browse files Browse the repository at this point in the history
  • Loading branch information
qwenode committed Jun 16, 2021
1 parent 9b45aa0 commit 51d662a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
12 changes: 12 additions & 0 deletions binary/string.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package binary

// 查找二进制数据
// https://bbs.csdn.net/topics/190107439?page=2
// https://github.com/elastic/go-windows/blob/master/utf16.go
// https://bbs.csdn.net/topics/390683473
// TODO 查询数据是否存在
// TODO 可传入基址,并返回数据当前对应的地址
//
func FindStringUTF16(data []byte, find string) {

}
1 change: 1 addition & 0 deletions cmd/input.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package cmd
9 changes: 9 additions & 0 deletions file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,12 @@ func CopyFile(src, dst string) error {
}
return nil
}

// MoveFile move file
func MoveFile(src, dst string) error {
err := CopyFile(src, dst)
if err != nil {
return err
}
return os.Remove(src)
}
30 changes: 30 additions & 0 deletions file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,33 @@ func TestGetLines(t *testing.T) {
})
}
}

func TestMoveFile(t *testing.T) {
type args struct {
src string
dst string
}
PutContents("./t_t_tsrc.jpg", []byte("1112222333"))
tests := []struct {
name string
args args
wantErr bool
}{
{
args: args{src: "./t_t_tsrc.jpg", dst: "./t_t_t.gg"},
wantErr: false,
},
{
args: args{src: "./t_t_tsrc.jpg", dst: "./."},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := MoveFile(tt.args.src, tt.args.dst); (err != nil) != tt.wantErr {
t.Errorf("MoveFile() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
os.Remove("./t_t_t.gg")
}

0 comments on commit 51d662a

Please sign in to comment.