diff options
author | Joe <rbo@gmx.us> | 2024-05-13 20:20:20 +0200 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-05-13 20:20:20 +0200 |
commit | 0ddfbf62fde8b8e0bde9a548b203d67b812ab61e (patch) | |
tree | 9843ed6d3420f1295e2b30355cfa743d4fa62202 /src/e_events.go | |
parent | gg (diff) | |
download | hardflip-0ddfbf62fde8b8e0bde9a548b203d67b812ab61e.tar.gz hardflip-0ddfbf62fde8b8e0bde9a548b203d67b812ab61e.tar.bz2 hardflip-0ddfbf62fde8b8e0bde9a548b203d67b812ab61e.tar.xz hardflip-0ddfbf62fde8b8e0bde9a548b203d67b812ab61e.tar.zst hardflip-0ddfbf62fde8b8e0bde9a548b203d67b812ab61e.zip |
fix
Diffstat (limited to 'src/e_events.go')
-rw-r--r-- | src/e_events.go | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/src/e_events.go b/src/e_events.go index 783e707..d954837 100644 --- a/src/e_events.go +++ b/src/e_events.go @@ -318,22 +318,47 @@ func e_mkdir(data *HardData, ui *HardUI) { func e_rename(data *HardData, ui *HardUI) error { tmp := data.litems.curr + name := "" + if tmp.is_dir() == false { + name = tmp.Host.Name + } else { + name = tmp.Dirs.Name + } - if len(ui.buff) == 0 || tmp == nil || tmp.is_dir() == true || - ui.buff == tmp.Host.Name { + if len(ui.buff) == 0 || tmp == nil || ui.buff == name { return nil } - new_host := e_deep_copy_host(data.litems.curr.Host) - new_host.Name = ui.buff - ui.insert_method = INSERT_MOVE - i_insert_host(data, &new_host) - data.litems.del(tmp) - file_path := data.data_dir + tmp.Host.parent.path() + tmp.Host.filename - if err := os.Remove(file_path); err != nil { - c_error_mode("can't remove " + file_path, err, &data.ui) - return err + if tmp.is_dir() == false { + new_host := e_deep_copy_host(data.litems.curr.Host) + new_host.Name = ui.buff + ui.insert_method = INSERT_MOVE + i_insert_host(data, &new_host) + data.litems.del(tmp) + file_path := data.data_dir + tmp.Host.parent.path() + tmp.Host.filename + if err := os.Remove(file_path); err != nil { + c_error_mode("can't remove " + file_path, err, &data.ui) + return err + } + return nil + } else { + old_path := data.data_dir + tmp.Dirs.path() + new_path := data.data_dir + tmp.Dirs.Parent.path() + data.ui.buff + if err := os.Rename(old_path, new_path); err != nil { + c_error_mode("can't rename " + old_path, err, &data.ui) + return err + } + path := tmp.Dirs.Parent.path() + e_reload_data(data) + for curr := data.litems.head; curr != nil; curr = curr.next { + if curr.is_dir() == true && + curr.Dirs.Name == ui.buff && + curr.Dirs.Parent.path() == path { + data.litems.curr = curr + return nil + } + } + return nil } - return nil } func e_set_drive_keys(data *HardData) { |