/* * Move up one directory */ void on_restore_up_button_clicked(GtkButton *button, gpointer user_data) { split_path_and_filename(restore->fname, &restore->path, &restore->pnl, &restore->file, &restore->fnl); FillDirectory(restore->path, restore); }
/* * For a given file (path+filename), split into path and file, then * lookup the most recent backup in the catalog to get the JobId * and FileIndex, then insert them into the findex list. */ static bool insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *file, char *date) { strip_trailing_newline(file); split_path_and_filename(ua, rx, file); if (*rx->JobIds == 0) { Mmsg(rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, rx->ClientName); } else { Mmsg(rx->query, uar_jobids_fileindex, rx->JobIds, date, rx->path, rx->fname, rx->ClientName); } rx->found = false; /* Find and insert jobid and File Index */ if (!db_sql_query(ua->db, rx->query, jobid_fileindex_handler, (void *)rx)) { ua->error_msg(_("Query failed: %s. ERR=%s\n"), rx->query, db_strerror(ua->db)); } if (!rx->found) { ua->error_msg(_("No database record found for: %s\n"), file); // ua->error_msg("Query=%s\n", rx->query); return true; } return true; }
/* * Fill the fileWidget box with the contents of the current directory */ void restorePage::fillDirectory() { mainWin->waitEnter(); char modes[20], user[20], group[20], size[20], date[30]; char marked[10]; int pnl, fnl; POOLMEM *file = get_pool_memory(PM_FNAME); POOLMEM *path = get_pool_memory(PM_FNAME); fileWidget->clear(); m_console->write_dir(m_conn, "dir", false); QList<QTreeWidgetItem *> treeItemList; QStringList item; m_rx.setPattern("has no children\\.$"); bool first = true; while (m_console->read(m_conn) > 0) { char *p = m_console->msg(m_conn); char *l; strip_trailing_newline(p); if (*p == '$' || !*p) { continue; } if (first) { if (m_rx.indexIn(QString(p)) != -1) { continue; } first = false; } l = p; skip_nonspaces(&p); /* permissions */ *p++ = 0; bstrncpy(modes, l, sizeof(modes)); skip_spaces(&p); skip_nonspaces(&p); /* link count */ *p++ = 0; skip_spaces(&p); l = p; skip_nonspaces(&p); /* user */ *p++ = 0; skip_spaces(&p); bstrncpy(user, l, sizeof(user)); l = p; skip_nonspaces(&p); /* group */ *p++ = 0; bstrncpy(group, l, sizeof(group)); skip_spaces(&p); l = p; skip_nonspaces(&p); /* size */ *p++ = 0; bstrncpy(size, l, sizeof(size)); skip_spaces(&p); l = p; skip_nonspaces(&p); /* date/time */ skip_spaces(&p); skip_nonspaces(&p); *p++ = 0; bstrncpy(date, l, sizeof(date)); skip_spaces(&p); if (*p == '*') { bstrncpy(marked, "*", sizeof(marked)); p++; } else { bstrncpy(marked, " ", sizeof(marked)); } split_path_and_filename(p, path, &pnl, file, &fnl); item.clear(); item << "" << file << modes << user << group << size << date; if (item[1].endsWith("/")) { addDirectory(item[1]); } QTreeWidgetItem *ti = new QTreeWidgetItem((QTreeWidget *)0, item); ti->setTextAlignment(5, Qt::AlignRight); /* right align size */ if (strcmp(marked, "*") == 0) { ti->setIcon(0, QIcon(QString::fromUtf8(":images/check.png"))); ti->setData(0, Qt::UserRole, true); } else { ti->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png"))); ti->setData(0, Qt::UserRole, false); } treeItemList.append(ti); } fileWidget->clear(); fileWidget->insertTopLevelItems(0, treeItemList); for (int i=0; i<7; i++) { fileWidget->resizeColumnToContents(i); } free_pool_memory(file); free_pool_memory(path); mainWin->waitExit(); }
/* * Fill the CList box with files at path */ void FillDirectory(const char *path, Window *restore) { char pathbuf[MAXSTRING]; char modes[20], user[20], group[20], size[20], date[30]; char file[1000]; char marked[10]; gchar *text[NUM_COLUMNS] = {marked, file, modes, user, group, size, date}; GtkCList *list = restore->list; int row = 0; stop_director_reader(NULL); pm_strcpy(&restore->fname, path); gtk_entry_set_text(GTK_ENTRY(restore_dir), restore->fname); gtk_clist_freeze(list); gtk_clist_clear(list); bsnprintf(pathbuf, sizeof(pathbuf), "cd %s", path); Dmsg1(100, "%s\n", pathbuf); write_director(pathbuf); discard_to_prompt(); write_director("dir"); while (bnet_recv(UA_sock) > 0) { char *p = UA_sock->msg; char *l; strip_trailing_junk(UA_sock->msg); if (*p == '$') { break; } Dmsg1(200, "Got: %s\n", p); if (!*p) { continue; } l = p; skip_nonspaces(&p); /* permissions */ *p++ = 0; bstrncpy(modes, l, sizeof(modes)); skip_spaces(&p); skip_nonspaces(&p); /* link count */ *p++ = 0; skip_spaces(&p); l = p; skip_nonspaces(&p); /* user */ *p++ = 0; skip_spaces(&p); bstrncpy(user, l, sizeof(user)); l = p; skip_nonspaces(&p); /* group */ *p++ = 0; bstrncpy(group, l, sizeof(group)); skip_spaces(&p); l = p; skip_nonspaces(&p); /* size */ *p++ = 0; bstrncpy(size, l, sizeof(size)); skip_spaces(&p); l = p; skip_nonspaces(&p); /* date/time */ skip_spaces(&p); skip_nonspaces(&p); *p++ = 0; bstrncpy(date, l, sizeof(date)); skip_spaces(&p); if (*p == '*') { bstrncpy(marked, "x", sizeof(marked)); p++; } else { bstrncpy(marked, " ", sizeof(marked)); } split_path_and_filename(p, &restore->path, &restore->pnl, &restore->file, &restore->fnl); // Dmsg1(000, "restore->fname=%s\n", restore->fname); bstrncpy(file, restore->file, sizeof(file)); // printf("modes=%s user=%s group=%s size=%s date=%s file=%s\n", // modes, user, group, size, date, file); gtk_clist_append(list, text); row++; } /* Fix up length of file column */ gtk_clist_set_column_width(list, FILE_COLUMN, gtk_clist_optimal_column_width(list, FILE_COLUMN)); gtk_clist_set_column_width(list, MODES_COLUMN, gtk_clist_optimal_column_width(list, MODES_COLUMN)); gtk_clist_thaw(list); start_director_reader(NULL); }