void user_select_files_from_tree(TREE_CTX *tree)
{
char cwd[2000];
+ /* Get a new context so we don't destroy restore command args */
+ UAContext *ua = new_ua_context(tree->ua->jcr);
+ ua->UA_sock = tree->ua->UA_sock; /* patch in UA socket */
bsendmsg(tree->ua, _(
"\nYou are now entering file selection mode where you add and\n"
bsendmsg(tree->ua, _("cwd is: %s\n"), cwd);
for ( ;; ) {
int found, len, stat, i;
- if (!get_cmd(tree->ua, "$ ")) {
+ if (!get_cmd(ua, "$ ")) {
break;
}
- parse_ua_args(tree->ua);
- if (tree->ua->argc == 0) {
- return;
+ parse_ua_args(ua);
+ if (ua->argc == 0) {
+ break;
}
- len = strlen(tree->ua->argk[0]);
+ len = strlen(ua->argk[0]);
found = 0;
stat = 0;
for (i=0; i<(int)comsize; i++) /* search for command */
- if (strncasecmp(tree->ua->argk[0], _(commands[i].key), len) == 0) {
- stat = (*commands[i].func)(tree->ua, tree); /* go execute command */
+ if (strncasecmp(ua->argk[0], _(commands[i].key), len) == 0) {
+ stat = (*commands[i].func)(ua, tree); /* go execute command */
found = 1;
break;
}
break;
}
}
+ ua->UA_sock = NULL; /* don't release restore socket */
+ free_ua_context(ua); /* get rid of temp UA context */
}
int type;
strip_trailing_junk(row[1]);
- if (*row[1] == 0) {
+ if (*row[1] == 0) { /* no filename => directory */
if (*row[0] != '/') { /* Must be Win32 directory */
type = TN_DIR_NLS;
} else {
} else {
type = TN_FILE;
}
- bsnprintf(fname, sizeof(fname), "%s%s", row[0]?row[0]:"", row[1]?row[1]:"");
+ bsnprintf(fname, sizeof(fname), "%s%s", row[0], row[1]);
if (tree->avail_node) {
node = tree->avail_node;
} else {
fdbr.FileId = 0;
fdbr.JobId = node->JobId;
if (db_get_file_attributes_record(ua->jcr, ua->db, cwd, &fdbr)) {
- uint32_t LinkFI;
+ int32_t LinkFI;
decode_stat(fdbr.LStat, &statp, &LinkFI); /* decode stat pkt */
/*
* If we point to a hard linked file, traverse the tree to
fdbr.FileId = 0;
fdbr.JobId = node->JobId;
if (db_get_file_attributes_record(ua->jcr, ua->db, cwd, &fdbr)) {
- uint32_t LinkFI;
+ int32_t LinkFI;
decode_stat(fdbr.LStat, &statp, &LinkFI); /* decode stat pkt */
ls_output(buf, cwd, node->extract, &statp);
bsendmsg(ua, "%s\n", buf);
if (!node) {
/* Try once more if Win32 drive -- make absolute */
if (ua->argk[1][1] == ':') { /* win32 drive */
- strcpy(cwd, "/");
- strcat(cwd, ua->argk[1]);
+ bstrncpy(cwd, "/", sizeof(cwd));
+ bstrncat(cwd, ua->argk[1], sizeof(cwd));
node = tree_cwd(cwd, tree->root, tree->node);
}
if (!node) {