Skip to content

Commit

Permalink
Some fixes when specifying files instead of directories.
Browse files Browse the repository at this point in the history
  • Loading branch information
cubiclesoft committed Mar 30, 2016
1 parent 1b932c5 commit 4067ff6
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions restore_shell_exts/main.php
Expand Up @@ -58,9 +58,32 @@ function shell_cmd_ls($line)
return;
}
$path = $result["path"];
$id = $result["dir"][count($result["dir"]) - 1]["id"];
$dirinfo = $result["dir"][count($result["dir"]) - 1];
$id = $dirinfo["id"];

if (!isset($dirinfo["file"])) $dirfiles = CB_GetDBFiles($id, false);
else
{
// Handle extraction of a single file.
$row = $dirinfo["file"];

$dirfiles = array();
$dirfiles[$row->name] = array(
"id" => $row->id,
"blocknum" => $row->blocknum,
"sharedblock" => (int)$row->sharedblock,
"name" => $row->name,
"symlink" => $row->symlink,
"attributes" => (int)$row->attributes,
"owner" => $row->owner,
"group" => $row->group,
"filesize" => $row->realfilesize,
"lastmodified" => $row->lastmodified,
"created" => $row->created,
);

$dirfiles = CB_GetDBFiles($id, false);
$id = $row->pid;
}

if (!isset($args["opts"]["regex"])) $args["opts"]["regex"] = array('/.*/');

Expand Down Expand Up @@ -228,6 +251,15 @@ function shell_cmd_cd($line)
return;
}

$dirinfo = $result["dir"][count($result["dir"]) - 1];

if (isset($dirinfo["file"]))
{
CB_DisplayError("The specified path '" . $path . "' is a file.", false, false);

return;
}

$pathstack = $result["dir"];
}

Expand Down

0 comments on commit 4067ff6

Please sign in to comment.