more initial changes
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package mover
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Move moves the file to destDir/destName, creating directories as needed.
|
||||
func Move(src, destDir, destName string) (string, error) {
|
||||
if err := os.MkdirAll(destDir, 0o755); err != nil {
|
||||
return "", fmt.Errorf("mkdir %s: %w", destDir, err)
|
||||
}
|
||||
destPath := filepath.Join(destDir, destName)
|
||||
if err := os.Rename(src, destPath); err != nil {
|
||||
return "", fmt.Errorf("rename %s -> %s: %w", src, destPath, err)
|
||||
}
|
||||
return destPath, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user