mirror of
https://github.com/derfenix/photocatalog.git
synced 2026-03-12 06:34:57 +03:00
22 lines
394 B
Go
22 lines
394 B
Go
package modes
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
type Move struct {
|
|
}
|
|
|
|
func (m Move) PlaceIt(sourcePath, targetPath string, mode os.FileMode) error {
|
|
if err := os.Rename(sourcePath, targetPath); err != nil {
|
|
return fmt.Errorf("rename %s to %s: %w", sourcePath, targetPath, err)
|
|
}
|
|
|
|
if err := os.Chmod(targetPath, mode); err != nil {
|
|
return fmt.Errorf("chmod hard link: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|