void TaskListPanel::RenameTask() { const TCHAR *oldname = get_cursor_name(); StaticString<40> newname(oldname); if (ClearSuffix(newname.buffer(), _T(".cup"))) { MessageBoxX(_("Can't rename .CUP files"), _("Rename Error"), MB_ICONEXCLAMATION); return; } ClearSuffix(newname.buffer(), _T(".tsk")); if (!TextEntryDialog(*(SingleWindow *)wf.get_root_owner(), newname)) return; newname.append(_T(".tsk")); TCHAR oldpath[MAX_PATH]; TCHAR newpath[MAX_PATH]; LocalPath(oldpath, oldname); LocalPath(newpath, newname.c_str()); File::Rename(oldpath, newpath); task_store->Scan(); RefreshView(); }
void TaskListPanel::RenameTask() { const unsigned cursor_index = GetList().GetCursorIndex(); if (cursor_index >= task_store->Size()) return; const TCHAR *oldname = task_store->GetName(cursor_index); StaticString<40> newname(oldname); if (ClearSuffix(newname.buffer(), _T(".cup"))) { ShowMessageBox(_("Can't rename .CUP files"), _("Rename Error"), MB_ICONEXCLAMATION); return; } ClearSuffix(newname.buffer(), _T(".tsk")); if (!TextEntryDialog(newname)) return; newname.append(_T(".tsk")); TCHAR newpath[MAX_PATH]; LocalPath(newpath, _T("tasks")); Directory::Create(newpath); LocalPath(newpath, _T("tasks"), newname.c_str()); File::Rename(task_store->GetPath(cursor_index), newpath); task_store->Scan(more); RefreshView(); }