Files
techsuppgetinfo/DCIManager6/dci6-support/platform-conf.go
2026-04-04 00:09:02 +08:00

64 lines
1.2 KiB
Go

package main
import (
"errors"
"fmt"
"io"
"os"
)
func copyFiles(src, dst string) error {
isSrcExist, err := os.Stat(src)
if err != nil {
return err
}
if !isSrcExist.Mode().IsRegular() {
return &os.PathError{
Op: "copy",
Path: src,
Err: errors.New("не является обычным файлом"),
}
}
source, err := os.Open(src)
if err != nil {
return err
}
defer source.Close()
destination, err := os.Create(dst)
if err != nil {
return err
}
defer destination.Close()
_, err = io.Copy(destination, source)
return err
}
func getIspFileNames(dirName string) ([]string, []error) {
var fileList []string
var errs []error
ispList, err := os.ReadDir(dirName)
if err != nil {
err = fmt.Errorf("Ошибка при получении содержимого директории %s : %s", dirName, err)
errs = append(errs, err)
err = nil
}
for _, entry := range ispList {
dirPath := dirName + "/" + entry.Name()
if entry.IsDir() {
interList, interErrs := getIspFileNames(dirPath)
for _, ie := range interErrs {
errs = append(errs, ie)
}
for _, il := range interList {
fileList = append(fileList, il)
}
}
fileList = append(fileList, dirPath)
}
return fileList, errs
}