summaryrefslogtreecommitdiff
path: root/backup.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-31 09:19:15 -0500
committerJeff Carr <[email protected]>2024-10-31 09:19:15 -0500
commit08757bc3150953870b2e56ec82bb82027ffbaa7a (patch)
tree26b4d8c4dd63b7c354e9489587f94203c57fb74a /backup.go
parentcc0ca1dd7caf5aa93624428a2d254b71e8b09a81 (diff)
code cleanups
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'backup.go')
-rw-r--r--backup.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/backup.go b/backup.go
deleted file mode 100644
index 2834993..0000000
--- a/backup.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package virtbuf
-
-// thank chatgpt for this because why. why write this if you can have it
-// kick this out in 30 seconds
-
-import (
- "errors"
- "fmt"
- "io"
- "log"
- "os"
- "path/filepath"
-)
-
-func backupFiles(srcDir string, destDir string) error {
- // Create the destination directory
- err := os.MkdirAll(destDir, os.ModePerm)
- if err != nil {
- return errors.New(fmt.Sprintf("Failed to create directory: %v", err))
- }
-
- // Read the contents of the source directory
- entries, err := os.ReadDir(srcDir)
- if err != nil {
- return errors.New(fmt.Sprintf("Failed to read directory: %v", err))
- }
-
- // Iterate over the entries in the source directory
- for _, entry := range entries {
- // Skip directories and files that do not have the .test extension
- if entry.IsDir() {
- continue
- }
-
- log.Println("backing up file", entry.Name())
- srcPath := filepath.Join(srcDir, entry.Name())
- destPath := filepath.Join(destDir, entry.Name())
-
- // Copy the file
- if err := copyFile(srcPath, destPath); err != nil {
- return errors.New(fmt.Sprintf("Failed to copy file %s: %v", entry.Name(), err))
- }
- }
- return nil
-}
-
-// copyFile copies a file from src to dest
-func copyFile(src, dest string) error {
- srcFile, err := os.Open(src)
- if err != nil {
- return err
- }
- defer srcFile.Close()
-
- destFile, err := os.Create(dest)
- if err != nil {
- return err
- }
- defer destFile.Close()
-
- // Copy the content
- _, err = io.Copy(destFile, srcFile)
- return err
-}