initial commit

This commit is contained in:
2025-12-10 22:50:35 +09:00
parent 8cf674c9e5
commit 6b76389942
12 changed files with 393 additions and 493 deletions

39
server/utils/copy_file.go Normal file
View File

@@ -0,0 +1,39 @@
package utils
import (
"io"
"os"
)
func CopyFile(src, dst string) error {
sourceFileStat, err := os.Stat(src)
if err != nil {
return err
}
if !sourceFileStat.Mode().IsRegular() {
return os.ErrInvalid
}
source, err := os.Open(src)
if err != nil {
return err
}
defer func() {
_ = source.Close()
}()
destination, err := os.Create(dst)
if err != nil {
return err
}
defer func() {
_ = destination.Close()
}()
if _, err := io.Copy(destination, source); err != nil {
return err
}
return os.Chmod(dst, sourceFileStat.Mode())
}