tune update db
This commit is contained in:
34
pkg/osx/file.go
Normal file
34
pkg/osx/file.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package osx
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Copy copies a file from source to destination
|
||||
func Copy(from, to string) error {
|
||||
// Open the source file for reading
|
||||
srcFile, err := os.Open(from)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer srcFile.Close()
|
||||
|
||||
// Create the destination file for writing
|
||||
dstFile, err := os.Create(to)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer dstFile.Close()
|
||||
|
||||
// Use a buffer to copy the file in chunks
|
||||
buf := make([]byte, 1024*1024) // 1 MB buffer
|
||||
|
||||
// Copy the data from srcFile to dstFile
|
||||
_, err = io.CopyBuffer(dstFile, srcFile, buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user