mirror of
https://github.com/derfenix/photocatalog.git
synced 2026-03-11 21:35:34 +03:00
Full application rewrite
This commit is contained in:
21
internal/organizer/modes/move.go
Normal file
21
internal/organizer/modes/move.go
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user